ipyvasp 1.0.1__py2.py3-none-any.whl → 1.0.2__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.
@@ -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
 
@@ -2593,7 +2591,7 @@ def sort_poscar(poscar_data, new_order):
2593
2591
  for i, k in enumerate(data["types"].keys())
2594
2592
  if len(data["types"][k]) != 0
2595
2593
  }
2596
-
2594
+ data["SYSTEM"] = "".join(data["types"].keys()) # Update system name
2597
2595
  return serializer.PoscarData(data)
2598
2596
 
2599
2597
  def remove_atoms(poscar_data, func, fillby=None):
@@ -2650,7 +2648,7 @@ def remove_atoms(poscar_data, func, fillby=None):
2650
2648
  for i, k in enumerate(new_types.keys())
2651
2649
  if len(new_types[k]) != 0
2652
2650
  }
2653
-
2651
+ data["SYSTEM"] = "".join(data["types"].keys()) # Update system name
2654
2652
  return serializer.PoscarData(data) # Return new POSCAR
2655
2653
 
2656
2654
 
ipyvasp/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.0.1"
1
+ __version__ = "1.0.2"
@@ -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
@@ -25,15 +25,19 @@ from einteract import patched_plotly
25
25
  from .spatial_toolkit import to_R3, rotation
26
26
  from ..utils import _sig_kwargs
27
27
 
28
+ try:
29
+ from IPython.display import set_matplotlib_formats # old style in < py3.9
30
+ except ImportError:
31
+ from matplotlib_inline.backend_inline import set_matplotlib_formats
28
32
 
29
33
  def global_matplotlib_settings(rcParams={}, display_format="svg"):
30
34
  "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
-
35
+ # Set display format only if the backend is the default inline backend.
36
+ # This avoids interfering with other backends like 'ipympl' which are
37
+ # required for interactive plotting.
38
+ if get_ipython() and "inline" in mpl.get_backend():
39
+ set_matplotlib_formats(display_format)
40
+
37
41
  # Gloabal settings matplotlib with some defaults
38
42
  rcParams = {
39
43
  "axes.linewidth": 0.4,
@@ -891,7 +895,7 @@ def plt2text(
891
895
  if plt_fig == None:
892
896
  plt_fig = plt.gcf()
893
897
  plot_bytes = BytesIO()
894
- plt.savefig(plot_bytes, format="png", dpi=600)
898
+ plt_fig.savefig(plot_bytes, format="png", dpi=600)
895
899
  img = PIL.Image.open(plot_bytes)
896
900
  # crop
897
901
  if crop:
@@ -952,9 +956,9 @@ def plt2html(plt_fig=None, transparent=True):
952
956
  if plt_fig is None:
953
957
  plt_fig = plt.gcf()
954
958
  plot_bytes = BytesIO()
955
- plt.savefig(plot_bytes, format="svg", transparent=transparent)
959
+ plt_fig.savefig(plot_bytes, format="svg", transparent=transparent)
956
960
 
957
- _ = plt.clf() # Clear other display
961
+ plt.close(plt_fig) # Close to avoid auto display in notebook
958
962
  return HTML("<svg" + plot_bytes.getvalue().decode("utf-8").split("<svg")[1])
959
963
 
960
964
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ipyvasp
3
- Version: 1.0.1
3
+ Version: 1.0.2
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,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=YVUgI4ne0qAZCTwjFoITAv34KcRMoHotpAeNuAx-dW8,105935
5
- ipyvasp/_version.py,sha256=j9q3lYMZra0QrErNnn9E5GNXxWLOlDgeOkmX8oXa7ro,23
4
+ ipyvasp/_lattice.py,sha256=-RQzY7jjNOT5xltXzLkJLf3ZIspKk3jktGVwAaew8ao,106340
5
+ ipyvasp/_version.py,sha256=LZTFaiDdXahAtu6Prb5WEPk4QX_pfMd7zDoNQSzcGsI,23
6
6
  ipyvasp/bsdos.py,sha256=omEiQrdbyZDI0Vd39bktzEyw2Il_w9rFsmYR_jEF-Xk,32180
7
7
  ipyvasp/cli.py,sha256=aWFEVhNmnW8eSOp5uh95JaDwLQ9K9nlCQcbnOSuhWgw,6844
8
8
  ipyvasp/evals_dataframe.py,sha256=KWbkvQJSyXeTSG6LJGcZKs0s5-tor5uPee2P8FJd7vs,20759
@@ -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=Pz5ZBsInM3Y2tmNxKPGEkX6pg81BDptcTIK7b3upbVg,36560
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.2.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
21
+ ipyvasp-1.0.2.dist-info/METADATA,sha256=l336yZiQA8J7QQvW3afAJnDyUcL8I1bhkY6FSG4jJ5c,3220
22
+ ipyvasp-1.0.2.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
23
+ ipyvasp-1.0.2.dist-info/entry_points.txt,sha256=aU-gGjQG2Q8XfxDlNc_8__cwfp8WG2K5ZgFPInTm2jg,45
24
+ ipyvasp-1.0.2.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
25
+ ipyvasp-1.0.2.dist-info/RECORD,,