ipyvasp 0.9.90__tar.gz → 0.9.93__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.
Files changed (31) hide show
  1. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/PKG-INFO +7 -3
  2. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/README.md +5 -2
  3. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/__init__.py +1 -1
  4. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/_enplots.py +20 -4
  5. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/_lattice.py +13 -4
  6. ipyvasp-0.9.93/ipyvasp/_version.py +1 -0
  7. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/bsdos.py +1 -0
  8. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/core/plot_toolkit.py +3 -2
  9. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/lattice.py +4 -4
  10. ipyvasp-0.9.93/ipyvasp/widgets.py +1079 -0
  11. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp.egg-info/PKG-INFO +7 -3
  12. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp.egg-info/requires.txt +2 -1
  13. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/setup.py +2 -1
  14. ipyvasp-0.9.90/ipyvasp/_version.py +0 -1
  15. ipyvasp-0.9.90/ipyvasp/widgets.py +0 -1158
  16. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/LICENSE +0 -0
  17. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/__main__.py +0 -0
  18. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/cli.py +0 -0
  19. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/core/__init__.py +0 -0
  20. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/core/parser.py +0 -0
  21. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/core/serializer.py +0 -0
  22. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/core/spatial_toolkit.py +0 -0
  23. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/evals_dataframe.py +0 -0
  24. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/misc.py +0 -0
  25. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/potential.py +0 -0
  26. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp/utils.py +0 -0
  27. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp.egg-info/SOURCES.txt +0 -0
  28. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp.egg-info/dependency_links.txt +0 -0
  29. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp.egg-info/entry_points.txt +0 -0
  30. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/ipyvasp.egg-info/top_level.txt +0 -0
  31. {ipyvasp-0.9.90 → ipyvasp-0.9.93}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ipyvasp
3
- Version: 0.9.90
3
+ Version: 0.9.93
4
4
  Summary: A processing tool for VASP DFT input/output processing in Jupyter Notebook.
5
5
  Home-page: https://github.com/massgh/ipyvasp
6
6
  Author: Abdul Saboor
@@ -20,9 +20,10 @@ Requires-Dist: scipy==1.9.1
20
20
  Requires-Dist: ipywidgets>=8.0.4
21
21
  Requires-Dist: pillow>=9.3.0
22
22
  Requires-Dist: pandas==1.4.4
23
- Requires-Dist: plotly==5.14.1
23
+ Requires-Dist: plotly==6.0.1
24
24
  Requires-Dist: requests==2.28.1
25
25
  Requires-Dist: typer==0.9.0
26
+ Requires-Dist: einteract
26
27
  Provides-Extra: extra
27
28
  Requires-Dist: jupyterlab>=3.5.2; extra == "extra"
28
29
  Requires-Dist: ipython>=8.7; extra == "extra"
@@ -30,7 +31,10 @@ Requires-Dist: ase>=3.22.1; extra == "extra"
30
31
  Requires-Dist: nglview>=3.0.4; extra == "extra"
31
32
 
32
33
 
33
- # ipyvasp
34
+ # IPyVASP
35
+
36
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15482350.svg)](https://doi.org/10.5281/zenodo.15482350)
37
+ [![PyPI Downloads](https://static.pepy.tech/badge/ipyvasp)](https://pepy.tech/projects/ipyvasp)
34
38
 
35
39
  An VASP-based DFT pre and post processing tool.
36
40
 
@@ -1,4 +1,7 @@
1
- # ipyvasp
1
+ # IPyVASP
2
+
3
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15482350.svg)](https://doi.org/10.5281/zenodo.15482350)
4
+ [![PyPI Downloads](https://static.pepy.tech/badge/ipyvasp)](https://pepy.tech/projects/ipyvasp)
2
5
 
3
6
  An VASP-based DFT pre and post processing tool.
4
7
 
@@ -41,4 +44,4 @@ Apply operations on POSCAR and simultaneously view using plotly's `FigureWidget`
41
44
  ![snip](op.png)
42
45
 
43
46
 
44
- More coming soon!
47
+ More coming soon!
@@ -31,7 +31,7 @@ from .bsdos import *
31
31
  from .potential import *
32
32
  from .evals_dataframe import *
33
33
  from .utils import *
34
- from .widgets import Files, BandsWidget, KpathWidget, summarize, load_results
34
+ from .widgets import Files, BandsWidget, KPathWidget, summarize, load_results
35
35
  from .core import plot_toolkit, spatial_toolkit
36
36
  from .core.spatial_toolkit import to_basis, to_R3, get_TM, get_bz, rotation
37
37
  from .core.plot_toolkit import (
@@ -774,7 +774,7 @@ def _format_rgb_data(
774
774
 
775
775
  # Now process data to make single data for faster plotting.
776
776
  txt = "Projection: [{}]</br>Value:".format(", ".join(labels))
777
- K, E, C, S, PT, OT, KT, ET = [], [], [], [], [], [], [], []
777
+ K, E, C, S, PT, OT, KT, ET, jKbop = [], [], [], [], [], [], [], [], []
778
778
  for i, b in enumerate(indices):
779
779
  K = [*K, *data["kpath"], np.nan]
780
780
  E = [*E, *data["evals"][:, i], np.nan]
@@ -800,6 +800,19 @@ def _format_rgb_data(
800
800
  "",
801
801
  ] # Add bands subscripts to labels.
802
802
 
803
+ jKbop = [*jKbop, *[
804
+ {
805
+ "nk":j+1,
806
+ **{f"k{u}":v for u,v in zip("xyz",xyz)},
807
+ "nb":b+1,
808
+ "occ":occ,
809
+ **{c:v for c,v in zip("rgb",rgb)}
810
+ }
811
+ for (j, xyz), occ,rgb in zip(
812
+ enumerate(data["kpoints"]), data["occs"][:, i],data["norms"][:, i]
813
+ )
814
+ ], {k:np.nan for k in ("nk","kx","ky","kz","nb","occ","r","g","b")}]
815
+
803
816
  T = [
804
817
  f"</br>{p} </br></br>Band: {e} {o}</br>{k}"
805
818
  for (p, e, o, k) in zip(PT, ET, OT, KT)
@@ -810,6 +823,7 @@ def _format_rgb_data(
810
823
  "C": C,
811
824
  "S": S,
812
825
  "T": T,
826
+ "jKbop": jKbop,
813
827
  "labels": labels,
814
828
  } # K, energy, marker color, marker size, text, labels that get changed
815
829
 
@@ -833,7 +847,7 @@ def _fmt_labels(ticklabels):
833
847
 
834
848
  @gu._fmt_doc(_docs)
835
849
  def iplot_bands(
836
- K, E, fig=None, elim=None, kticks=None, interp=None, title=None, **kwargs
850
+ K, E, occs = None, fig=None, elim=None, kticks=None, interp=None, title=None, **kwargs
837
851
  ):
838
852
  """Plot band structure using plotly.
839
853
  {params}\n {K}\n {E}
@@ -854,10 +868,10 @@ def iplot_bands(
854
868
  data = _format_rgb_data(
855
869
  K,
856
870
  E,
857
- [E],
871
+ [E], # don't let it fail if no projections
858
872
  ["X"],
859
873
  interp,
860
- E,
874
+ E if occs is None else occs,
861
875
  np.array([K, K, K]).reshape((-1, 3)),
862
876
  maxwidth=1,
863
877
  indices=indices,
@@ -873,6 +887,7 @@ def iplot_bands(
873
887
  kwargs = {
874
888
  "mode": "markers + lines",
875
889
  "marker": dict(size=0.1),
890
+ "customdata": [{k:v for k,v in d.items() if not k in 'rgb'} for d in data["jKbop"]], # useless rgb data to skip
876
891
  **kwargs,
877
892
  } # marker so that it is selectable by box, otherwise it does not
878
893
  fig.add_trace(go.Scatter(x=K, y=E, hovertext=T, **kwargs))
@@ -955,6 +970,7 @@ def iplot_rgb_lines(
955
970
  "color": C,
956
971
  "size": S,
957
972
  },
973
+ "customdata": data["jKbop"], # need for selection and hover template
958
974
  }
959
975
  ) # marker edge should be free
960
976
 
@@ -232,7 +232,7 @@ def periodic_table(selection=None):
232
232
  return ax
233
233
 
234
234
 
235
- def write_poscar(poscar_data, outfile=None, selective_dynamics=None, overwrite=False, comment=""):
235
+ def write_poscar(poscar_data, outfile=None, selective_dynamics=None, overwrite=False, comment="", scale=None):
236
236
  """Writes POSCAR data to a file or returns string
237
237
 
238
238
  Parameters
@@ -246,6 +246,8 @@ def write_poscar(poscar_data, outfile=None, selective_dynamics=None, overwrite=F
246
246
  If file already exists, overwrite=True changes it.
247
247
  comment: str
248
248
  Add comment, previous comment will be there too.
249
+ scale: float
250
+ Scale factor for the basis vectors. Default is provided by loaded data.
249
251
 
250
252
 
251
253
  .. note::
@@ -253,7 +255,14 @@ def write_poscar(poscar_data, outfile=None, selective_dynamics=None, overwrite=F
253
255
  """
254
256
  _comment = poscar_data.metadata.comment + comment
255
257
  out_str = f"{poscar_data.SYSTEM} # " + (_comment or "Created by ipyvasp")
256
- scale = poscar_data.metadata.scale
258
+
259
+ if scale is None:
260
+ scale = poscar_data.metadata.scale
261
+ elif not isinstance(scale, (int, float)):
262
+ raise TypeError("scale must be a number or None.")
263
+ elif scale == 0:
264
+ raise ValueError("scale can not be zero.")
265
+
257
266
  out_str += "\n {:<20.14f}\n".format(scale)
258
267
  out_str += "\n".join(
259
268
  ["{:>22.16f}{:>22.16f}{:>22.16f}".format(*a) for a in poscar_data.basis / scale]
@@ -550,9 +559,9 @@ class InvokeMaterialsProject:
550
559
  else:
551
560
  print(self._cif)
552
561
 
553
- def write_poscar(self, outfile=None, overwrite=False, comment=""):
562
+ def write_poscar(self, outfile=None, overwrite=False, comment="",scale=None):
554
563
  "Use `ipyvasp.lattice.POSCAR.write` if you need extra options."
555
- write_poscar(self.export_poscar(), outfile=outfile, overwrite=overwrite, comment=comment)
564
+ write_poscar(self.export_poscar(), outfile=outfile, overwrite=overwrite, comment=comment, scale=scale)
556
565
 
557
566
  def export_poscar(self):
558
567
  "Export poscar data form cif content."
@@ -0,0 +1 @@
1
+ __version__ = "0.9.93"
@@ -605,6 +605,7 @@ class Bands(_BandsDosBase):
605
605
  return iplot_bands(
606
606
  {"K": data.kpath, "indices": data.bands},
607
607
  data.evals[spin] - data.ezero,
608
+ occs = data.occs[spin],
608
609
  **kwargs,
609
610
  )
610
611
 
@@ -20,6 +20,7 @@ import PIL # For text image.
20
20
 
21
21
  import plotly.graph_objects as go
22
22
  from plotly.io._base_renderers import open_html_in_browser
23
+ from einteract import patched_plotly
23
24
 
24
25
  from .spatial_toolkit import to_R3, rotation
25
26
  from ..utils import _sig_kwargs
@@ -1011,7 +1012,7 @@ def iplot2html(fig, outfile=None, modebar=True):
1011
1012
  def iplot2widget(fig, fig_widget=None, template=None):
1012
1013
  "Converts plotly's figure to FigureWidget by copying attributes and data. If fig_widget is provided, it will update it. Adds template if provided. If fig is FigureWidget, it is just returned"
1013
1014
  if isinstance(fig, go.FigureWidget):
1014
- return fig
1015
+ return patched_plotly(fig) # add attributes selected and clicked
1015
1016
 
1016
1017
  if not isinstance(fig, go.Figure):
1017
1018
  raise ValueError("fig must be instance of plotly.graph_objects.Figure")
@@ -1035,7 +1036,7 @@ def iplot2widget(fig, fig_widget=None, template=None):
1035
1036
  for data in fig.data:
1036
1037
  fig_widget.add_trace(data)
1037
1038
 
1038
- return fig_widget
1039
+ return patched_plotly(fig_widget) # add attributes selected and clicked
1039
1040
 
1040
1041
  @_sig_kwargs(plt.imshow, ('ax','X'))
1041
1042
  def image2plt(image_or_fname, ax = None, crop = None, **kwargs):
@@ -342,7 +342,7 @@ class POSCAR:
342
342
  [
343
343
  f"{k}={v}"
344
344
  for k, v in zip(
345
- "abcαβγ", (*self.data.norms.round(3), *self.data.angles.round(3))
345
+ ['a','b','c','alpha','beta','gamma'], (*self.data.norms.round(3), *self.data.angles.round(3))
346
346
  )
347
347
  ]
348
348
  )
@@ -436,10 +436,10 @@ class POSCAR:
436
436
  return weas_viewer(self, **kwargs)
437
437
 
438
438
  def view_kpath(self, height='400px'):
439
- "Initialize a KpathWidget instance to view kpath for current POSCAR, and you can select others too."
440
- from .widgets import KpathWidget
439
+ "Initialize a KPathWidget instance to view kpath for current POSCAR, and you can select others too."
440
+ from .widgets import KPathWidget
441
441
 
442
- return KpathWidget([self.path,],height=height)
442
+ return KPathWidget([self.path,],height=height)
443
443
 
444
444
  @_sub_doc(plat.iplot_lattice)
445
445
  @_sig_kwargs(plat.iplot_lattice, ("poscar_data",))