ipyvasp 1.0.8__tar.gz → 1.1.0__tar.gz
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-1.0.8 → ipyvasp-1.1.0}/PKG-INFO +1 -1
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/_lattice.py +36 -25
- ipyvasp-1.1.0/ipyvasp/_version.py +1 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/bsdos.py +2 -2
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/core/parser.py +3 -14
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/core/plot_toolkit.py +1 -1
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/evals_dataframe.py +1 -1
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/widgets.py +5 -7
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp.egg-info/PKG-INFO +1 -1
- ipyvasp-1.0.8/ipyvasp/_version.py +0 -1
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/LICENSE +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/README.md +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/__init__.py +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/__main__.py +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/_enplots.py +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/cli.py +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/core/__init__.py +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/core/serializer.py +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/core/spatial_toolkit.py +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/lattice.py +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/misc.py +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/potential.py +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp/utils.py +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp.egg-info/SOURCES.txt +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp.egg-info/dependency_links.txt +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp.egg-info/entry_points.txt +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp.egg-info/requires.txt +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/ipyvasp.egg-info/top_level.txt +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/setup.cfg +0 -0
- {ipyvasp-1.0.8 → ipyvasp-1.1.0}/setup.py +0 -0
|
@@ -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
|
-
|
|
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
|
-
|
|
896
|
+
return points # return points for any processing by user.
|
|
886
897
|
|
|
887
898
|
|
|
888
899
|
# Cell
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.1.0"
|
|
@@ -270,7 +270,7 @@ class Bands(_BandsDosBase):
|
|
|
270
270
|
|
|
271
271
|
Parameters
|
|
272
272
|
----------
|
|
273
|
-
source : instance of `ipyvasp.DataSource` such as `ipyvasp.Vasprun` or
|
|
273
|
+
source : instance of `ipyvasp.DataSource` such as `ipyvasp.Vasprun` or a user defined subclass.
|
|
274
274
|
You can define your own class to parse data with same attributes and methods by subclassing `ipyvasp.DataSource`.
|
|
275
275
|
"""
|
|
276
276
|
|
|
@@ -627,7 +627,7 @@ class DOS(_BandsDosBase):
|
|
|
627
627
|
|
|
628
628
|
Parameters
|
|
629
629
|
----------
|
|
630
|
-
source : instance of `ipyvasp.DataSource` such as `ipyvasp.Vasprun` or
|
|
630
|
+
source : instance of `ipyvasp.DataSource` such as `ipyvasp.Vasprun` or a user defined subclass.
|
|
631
631
|
You can define your own class to parse data with same attributes and methods by subclassing `ipyvasp.DataSource`.
|
|
632
632
|
"""
|
|
633
633
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
__all__ = ["Vasprun", "
|
|
1
|
+
__all__ = ["Vasprun", "minify_vasprun", "xml2dict","read"]
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
4
|
from io import StringIO
|
|
@@ -14,7 +14,8 @@ from . import serializer
|
|
|
14
14
|
|
|
15
15
|
class DataSource:
|
|
16
16
|
"""Base class for all data sources. It provides a common interface to access data from different sources.
|
|
17
|
-
Subclass it to get data from a source and implement the
|
|
17
|
+
Subclass it to get data from a source such as recently implemented `vaspout.h5` file and implement the required
|
|
18
|
+
methods with same output as done in Vasprun class."""
|
|
18
19
|
|
|
19
20
|
def __init__(self, path, skipk=None):
|
|
20
21
|
self._path = Path(path).absolute()
|
|
@@ -122,18 +123,6 @@ class DataSource:
|
|
|
122
123
|
)
|
|
123
124
|
|
|
124
125
|
|
|
125
|
-
class Vaspout(DataSource):
|
|
126
|
-
"Read data from vaspout.h5 file on demand."
|
|
127
|
-
# These methods are accessible from parent class, but need here for including in sphinx documentation
|
|
128
|
-
get_evals_dataframe = DataSource.get_evals_dataframe
|
|
129
|
-
poscar = DataSource.poscar
|
|
130
|
-
dos = DataSource.dos
|
|
131
|
-
bands = DataSource.bands
|
|
132
|
-
|
|
133
|
-
def __init__(self, path, skipk=None):
|
|
134
|
-
# super().__init__(path, skipk)
|
|
135
|
-
raise NotImplementedError("Vaspout is not implemented yet.")
|
|
136
|
-
|
|
137
126
|
def read(file, start_match, stop_match=r'\n', nth_match=1, skip_last=False,apply=None):
|
|
138
127
|
"""Reads a part of the file between start_match and stop_match and returns a generator. It is lazy and fast.
|
|
139
128
|
`start_match` and `stop_match`(default is end of same line) are regular expressions. `nth_match` is the number of occurence of start_match to start reading.
|
|
@@ -937,7 +937,7 @@ def plt2text(
|
|
|
937
937
|
print(out_str)
|
|
938
938
|
|
|
939
939
|
|
|
940
|
-
def plt2html(plt_fig=None, transparent=
|
|
940
|
+
def plt2html(plt_fig=None, transparent=False):
|
|
941
941
|
"""Returns ``ipython.display.HTML(<svg of figure>)``. It clears figure after use. So ``plt.show()`` will not work after this.
|
|
942
942
|
|
|
943
943
|
Parameters
|
|
@@ -64,7 +64,7 @@ class EvalsDataFrame(pd.DataFrame):
|
|
|
64
64
|
Parameters
|
|
65
65
|
----------
|
|
66
66
|
source : DataSource
|
|
67
|
-
Data source to collect data from. Could be ``ipyvasp.Vasprun`` or ``ipyvasp.
|
|
67
|
+
Data source to collect data from. Could be ``ipyvasp.Vasprun`` or a user defined subclass of ``ipyvasp.DataSource``. Alternatively you can use ``DataSource.get_dataframe`` method to get dataframe directly.
|
|
68
68
|
spins : list
|
|
69
69
|
of spin indices [zero based here], In output data frame you will see corresponding spin number based on full data.
|
|
70
70
|
bands : list
|
|
@@ -275,9 +275,9 @@ class Files:
|
|
|
275
275
|
"Get KPathWidget instance with these files."
|
|
276
276
|
return KPathWidget(files = self.with_name('POSCAR'), height = height)
|
|
277
277
|
|
|
278
|
-
def bands_widget(self, height='450px'):
|
|
278
|
+
def bands_widget(self, height='450px',store_clicks=None):
|
|
279
279
|
"Get BandsWidget instance with these files."
|
|
280
|
-
return BandsWidget(files=self._files, height=height)
|
|
280
|
+
return BandsWidget(files=self._files, height=height, store_clicks=store_clicks)
|
|
281
281
|
|
|
282
282
|
def map(self,func, to_df=False):
|
|
283
283
|
"""Map files to a function that takes path as argument.
|
|
@@ -438,7 +438,7 @@ class PropsPicker(VBox): # NOTE: remove New Later
|
|
|
438
438
|
|
|
439
439
|
Parameters
|
|
440
440
|
----------
|
|
441
|
-
system_summary :
|
|
441
|
+
system_summary : DataSource.summary such as impelemented in Vasprun.
|
|
442
442
|
N : int, default is 3, number of projections to pick.
|
|
443
443
|
|
|
444
444
|
You can observe `projections` trait.
|
|
@@ -764,9 +764,7 @@ class BandsWidget(_ThemedFigureInteract):
|
|
|
764
764
|
@dl.callback('out-data')
|
|
765
765
|
def _load_data(self, file):
|
|
766
766
|
if not file: return # First time not available
|
|
767
|
-
self._bands = (
|
|
768
|
-
vp.Vasprun(file) if file.parts[-1].endswith('xml') else vp.Vaspout(file)
|
|
769
|
-
).bands
|
|
767
|
+
self._bands = vp.Vasprun(file).bands
|
|
770
768
|
self.params.ppicks.update(self.bands.source.summary)
|
|
771
769
|
self.params.krange.max = self.bands.source.summary.NKPTS - 1
|
|
772
770
|
self.params.krange.tooltip = f"Includes {self.bands.source.get_skipk()} non-zero weight kpoints"
|
|
@@ -912,7 +910,7 @@ class BandsWidget(_ThemedFigureInteract):
|
|
|
912
910
|
|
|
913
911
|
@property
|
|
914
912
|
def source(self):
|
|
915
|
-
"Returns data source object such as Vasprun or
|
|
913
|
+
"Returns data source object such as Vasprun or user defined subclass of DataSource."
|
|
916
914
|
return self.bands.source
|
|
917
915
|
|
|
918
916
|
@property
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.0.8"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|