ipyvasp 1.0.1__py2.py3-none-any.whl → 1.0.3__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 CHANGED
@@ -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="", scale=None):
235
+ def write_poscar(poscar_data, outfile=None, selective_dynamics=None, overwrite=False, comment="", scale=None, system=None):
236
236
  """Writes POSCAR data to a file or returns string
237
237
 
238
238
  Parameters
@@ -248,13 +248,15 @@ def write_poscar(poscar_data, outfile=None, selective_dynamics=None, overwrite=F
248
248
  Add comment, previous comment will be there too.
249
249
  scale: float
250
250
  Scale factor for the basis vectors. Default is provided by loaded data.
251
+ system: str
252
+ System name to be used in POSCAR file instead of the one in `poscar_data.SYSTEM`.
251
253
 
252
254
 
253
255
  .. note::
254
256
  POSCAR is only written in direct format even if it was loaded from cartesian format.
255
257
  """
256
258
  _comment = poscar_data.metadata.comment + comment
257
- out_str = f"{poscar_data.SYSTEM} # " + (_comment or "Created by ipyvasp")
259
+ out_str = f"{system or poscar_data.SYSTEM} # " + (_comment or "Created by ipyvasp")
258
260
 
259
261
  if scale is None:
260
262
  scale = poscar_data.metadata.scale
@@ -2296,10 +2298,6 @@ def set_boundary(poscar_data, a = [0,1], b = [0,1], c = [0,1]):
2296
2298
  del upos
2297
2299
  return serializer.PoscarData(data)
2298
2300
 
2299
-
2300
-
2301
-
2302
-
2303
2301
 
2304
2302
  def rotate_poscar(poscar_data, angle_deg, axis_vec):
2305
2303
  """Rotate a given POSCAR.
@@ -2380,7 +2378,7 @@ def convert_poscar(poscar_data, atoms_mapping, basis_factor):
2380
2378
 
2381
2379
 
2382
2380
  .. note::
2383
- This can be used to strain basis vectors uniformly only. For non-uniform strain, use :func:`ipyvasp.POSCAR.strain`.
2381
+ This can be used to strain basis vectors uniformly only. For non-uniform strain, use :func:`ipyvasp.POSCAR.deform`.
2384
2382
  """
2385
2383
  poscar_data = poscar_data.to_dict() # Avoid modifying original
2386
2384
  poscar_data["types"] = {
@@ -2412,7 +2410,7 @@ def convert_poscar(poscar_data, atoms_mapping, basis_factor):
2412
2410
  type(basis_factor)
2413
2411
  )
2414
2412
  )
2415
-
2413
+ poscar_data["SYSTEM"] = "".join(poscar_data["types"].keys()) # Update system name
2416
2414
  return serializer.PoscarData(poscar_data) # Return new POSCAR
2417
2415
 
2418
2416
 
@@ -2431,7 +2429,7 @@ def transform_poscar(poscar_data, transformation, fill_factor=2, tol=1e-2):
2431
2429
 
2432
2430
 
2433
2431
  .. note::
2434
- This function keeps underlying lattice same.
2432
+ This function keeps underlying lattice same. To apply strain, use `deform` function instead.
2435
2433
  """
2436
2434
  if callable(transformation):
2437
2435
  new_basis = np.array(transformation(*poscar_data.basis)) # mostly a tuple
@@ -2546,11 +2544,11 @@ def add_atoms(poscar_data, name, positions):
2546
2544
  data = poscar_data.to_dict() # Copy data to avoid modifying original
2547
2545
  data["types"] = unique # Update unique dictionary
2548
2546
  data["positions"] = new_pos # Update positions
2549
- data["SYSTEM"] = f'{data["SYSTEM"]}+{name}' # Update SYSTEM
2550
2547
  data["metadata"][
2551
2548
  "comment"
2552
2549
  ] = f'{data["metadata"]["comment"]} + Added {name!r}' # Update comment
2553
2550
 
2551
+ data["SYSTEM"] = "".join(data["types"].keys()) # Update system name
2554
2552
  return serializer.PoscarData(data) # Return new POSCAR
2555
2553
 
2556
2554
 
@@ -2574,6 +2572,7 @@ def replace_atoms(poscar_data, func, name):
2574
2572
  for i, k in enumerate(new_types.keys())
2575
2573
  if len(new_types[k]) != 0
2576
2574
  }
2575
+ data["SYSTEM"] = "".join(data["types"].keys()) # Update system name
2577
2576
  return serializer.PoscarData(data) # Return new POSCAR
2578
2577
 
2579
2578
  def sort_poscar(poscar_data, new_order):
@@ -2593,7 +2592,7 @@ def sort_poscar(poscar_data, new_order):
2593
2592
  for i, k in enumerate(data["types"].keys())
2594
2593
  if len(data["types"][k]) != 0
2595
2594
  }
2596
-
2595
+ data["SYSTEM"] = "".join(data["types"].keys()) # Update system name
2597
2596
  return serializer.PoscarData(data)
2598
2597
 
2599
2598
  def remove_atoms(poscar_data, func, fillby=None):
@@ -2650,7 +2649,7 @@ def remove_atoms(poscar_data, func, fillby=None):
2650
2649
  for i, k in enumerate(new_types.keys())
2651
2650
  if len(new_types[k]) != 0
2652
2651
  }
2653
-
2652
+ data["SYSTEM"] = "".join(data["types"].keys()) # Update system name
2654
2653
  return serializer.PoscarData(data) # Return new POSCAR
2655
2654
 
2656
2655
 
ipyvasp/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.0.1"
1
+ __version__ = "1.0.3"
ipyvasp/cli.py CHANGED
@@ -74,7 +74,7 @@ def get_gap(files: List[Path]):
74
74
  from .widgets import summarize
75
75
 
76
76
  def gap_summary(path):
77
- gap = Vasprun(path).bands.gap
77
+ gap = Vasprun(path, skipk=0).bands.gap # don't skip k-points here
78
78
  delattr(gap, "coords") # remove coords info
79
79
  d = gap.to_dict()
80
80
  d["kvbm"] = "(" + ",".join(str(round(k, 4)) for k in d["kvbm"]) + ")"
@@ -15,7 +15,7 @@ from matplotlib.patches import FancyArrowPatch
15
15
  from cycler import cycler
16
16
 
17
17
  from IPython import get_ipython
18
- from IPython.display import HTML, set_matplotlib_formats
18
+ from IPython.display import HTML
19
19
  import PIL # For text image.
20
20
 
21
21
  import plotly.graph_objects as go
@@ -26,14 +26,11 @@ from .spatial_toolkit import to_R3, rotation
26
26
  from ..utils import _sig_kwargs
27
27
 
28
28
 
29
- def global_matplotlib_settings(rcParams={}, display_format="svg"):
29
+ def global_matplotlib_settings(rcParams={}, display_format="svg"):
30
30
  "Set global matplotlib settings for notebook."
31
- # show SVG in notebook
32
- if shell := get_ipython():
33
- shell_name = shell.__class__.__name__
34
- if shell_name in ("ZMQInteractiveShell", "Shell"): # Shell for colab.
35
- set_matplotlib_formats(display_format)
36
-
31
+ if ip := get_ipython():
32
+ ip.run_line_magic("config", f"InlineBackend.figure_formats = ['{display_format}', 'svg', 'retina','png','jpeg']")
33
+
37
34
  # Gloabal settings matplotlib with some defaults
38
35
  rcParams = {
39
36
  "axes.linewidth": 0.4,
@@ -230,7 +227,6 @@ def get_axes(
230
227
  pass
231
228
 
232
229
  plt.subplots_adjust(**subplots_adjust_kwargs)
233
-
234
230
  return axs
235
231
 
236
232
 
@@ -891,7 +887,7 @@ def plt2text(
891
887
  if plt_fig == None:
892
888
  plt_fig = plt.gcf()
893
889
  plot_bytes = BytesIO()
894
- plt.savefig(plot_bytes, format="png", dpi=600)
890
+ plt_fig.savefig(plot_bytes, format="png", dpi=600)
895
891
  img = PIL.Image.open(plot_bytes)
896
892
  # crop
897
893
  if crop:
@@ -952,9 +948,9 @@ def plt2html(plt_fig=None, transparent=True):
952
948
  if plt_fig is None:
953
949
  plt_fig = plt.gcf()
954
950
  plot_bytes = BytesIO()
955
- plt.savefig(plot_bytes, format="svg", transparent=transparent)
951
+ plt_fig.savefig(plot_bytes, format="svg", transparent=transparent)
956
952
 
957
- _ = plt.clf() # Clear other display
953
+ plt.close(plt_fig) # Close to avoid auto display in notebook
958
954
  return HTML("<svg" + plot_bytes.getvalue().decode("utf-8").split("<svg")[1])
959
955
 
960
956
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ipyvasp
3
- Version: 1.0.1
3
+ Version: 1.0.3
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
@@ -28,7 +28,7 @@ Requires-Dist: einteract
28
28
  Requires-Dist: sympy
29
29
  Provides-Extra: extra
30
30
  Requires-Dist: jupyterlab>=3.5.2; extra == "extra"
31
- Requires-Dist: ipython>=8.7; extra == "extra"
31
+ Requires-Dist: ipython>=9.0; extra == "extra"
32
32
  Requires-Dist: ase>=3.22.1; extra == "extra"
33
33
  Requires-Dist: nglview>=3.0.4; extra == "extra"
34
34
 
@@ -1,10 +1,10 @@
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=YVUgI4ne0qAZCTwjFoITAv34KcRMoHotpAeNuAx-dW8,105935
5
- ipyvasp/_version.py,sha256=j9q3lYMZra0QrErNnn9E5GNXxWLOlDgeOkmX8oXa7ro,23
4
+ ipyvasp/_lattice.py,sha256=4xI8LBypEhTLFxSSsUCGSJjKesxcymIyYBLeM21sO6Q,106414
5
+ ipyvasp/_version.py,sha256=jESq7ftlDB8Kg0mmAcsPtQSIA_t3PZO7335uh0WruS4,23
6
6
  ipyvasp/bsdos.py,sha256=omEiQrdbyZDI0Vd39bktzEyw2Il_w9rFsmYR_jEF-Xk,32180
7
- ipyvasp/cli.py,sha256=aWFEVhNmnW8eSOp5uh95JaDwLQ9K9nlCQcbnOSuhWgw,6844
7
+ ipyvasp/cli.py,sha256=-Lf-qdTvs7WyrA4ALNLaoqxMjLsZkXdPviyQps3ezqg,6880
8
8
  ipyvasp/evals_dataframe.py,sha256=KWbkvQJSyXeTSG6LJGcZKs0s5-tor5uPee2P8FJd7vs,20759
9
9
  ipyvasp/lattice.py,sha256=NAe4cmXwkd6V0pRDTw1g5_CoNMfqOIT-NpyOSlSfyv0,33710
10
10
  ipyvasp/misc.py,sha256=ItSsG_aWiQZNRXM2F23atmNVdedyXFYtoShflYRvzOU,2645
@@ -14,12 +14,12 @@ ipyvasp/utils.py,sha256=1eVDhYzK3dr0AC_CouWrU3xIhbVJu7AABscV-qi_vAA,18000
14
14
  ipyvasp/widgets.py,sha256=JcLKjn_Wbi5VXgNOB-SB30dD_-dPTslaKFpJwGgr0Mg,53319
15
15
  ipyvasp/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  ipyvasp/core/parser.py,sha256=i1lMlfVPEA0-UFDz9lQnlVlMnVFBkEHBsqYPF3ez_2I,39805
17
- ipyvasp/core/plot_toolkit.py,sha256=XUB8VYBjv81WowafgLEyHELmzQn-PT36KwLJZKXIx_c,36304
17
+ ipyvasp/core/plot_toolkit.py,sha256=459jw5WELvEYWgAvDNF5pxmgEUB6UJIdIJDbTgthWoo,36233
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.1.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
21
- ipyvasp-1.0.1.dist-info/METADATA,sha256=n2ix06x91IihFM--xF5l9914VZIsbg_CO4PahbgVJlY,3220
22
- ipyvasp-1.0.1.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
23
- ipyvasp-1.0.1.dist-info/entry_points.txt,sha256=aU-gGjQG2Q8XfxDlNc_8__cwfp8WG2K5ZgFPInTm2jg,45
24
- ipyvasp-1.0.1.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
25
- ipyvasp-1.0.1.dist-info/RECORD,,
20
+ ipyvasp-1.0.3.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
21
+ ipyvasp-1.0.3.dist-info/METADATA,sha256=Owasm1AcDcwSx5cG2PJ_AfoIeBKLlcIhawG2AUeTDfE,3220
22
+ ipyvasp-1.0.3.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
23
+ ipyvasp-1.0.3.dist-info/entry_points.txt,sha256=aU-gGjQG2Q8XfxDlNc_8__cwfp8WG2K5ZgFPInTm2jg,45
24
+ ipyvasp-1.0.3.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
25
+ ipyvasp-1.0.3.dist-info/RECORD,,