ipyvasp 0.9.87__tar.gz → 0.9.89__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-0.9.87 → ipyvasp-0.9.89}/PKG-INFO +1 -1
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/__init__.py +1 -1
- ipyvasp-0.9.89/ipyvasp/_version.py +1 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/misc.py +7 -2
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/utils.py +28 -11
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/widgets.py +2 -2
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp.egg-info/PKG-INFO +1 -1
- ipyvasp-0.9.87/ipyvasp/_version.py +0 -1
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/LICENSE +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/README.md +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/__main__.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/_enplots.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/_lattice.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/bsdos.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/cli.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/core/__init__.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/core/parser.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/core/plot_toolkit.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/core/serializer.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/core/spatial_toolkit.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/evals_dataframe.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/lattice.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp/potential.py +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp.egg-info/SOURCES.txt +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp.egg-info/dependency_links.txt +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp.egg-info/entry_points.txt +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp.egg-info/requires.txt +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/ipyvasp.egg-info/top_level.txt +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/setup.cfg +0 -0
- {ipyvasp-0.9.87 → ipyvasp-0.9.89}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.9.89"
|
|
@@ -3,6 +3,7 @@ __all__ = ["parse_text", "get_bib", "get_E0", "OUTCAR"]
|
|
|
3
3
|
import requests
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from itertools import islice
|
|
6
|
+
import numpy as np
|
|
6
7
|
|
|
7
8
|
from .core import parser as vp
|
|
8
9
|
from .utils import _sig_kwargs, _sub_doc
|
|
@@ -35,8 +36,8 @@ def get_bib(DOI):
|
|
|
35
36
|
|
|
36
37
|
return response.status_code
|
|
37
38
|
|
|
38
|
-
def get_E0(path: Path = 'OSZICAR'):
|
|
39
|
-
"Get the E0 from the last line of OSZICAR."
|
|
39
|
+
def get_E0(path: Path = 'OSZICAR',nsteps=0):
|
|
40
|
+
"Get the E0 from the last line of OSZICAR. If `nsteps > 0`, returns as many available last steps ."
|
|
40
41
|
fh = Path(path)
|
|
41
42
|
if fh.is_file():
|
|
42
43
|
lines = fh.read_text().splitlines()
|
|
@@ -51,6 +52,10 @@ def get_E0(path: Path = 'OSZICAR'):
|
|
|
51
52
|
|
|
52
53
|
if not line.lstrip().startswith('1'):
|
|
53
54
|
print(f"Calculation may not be converged for {path!r}\n{line}")
|
|
55
|
+
|
|
56
|
+
if nsteps > 0: # not allow negative ones
|
|
57
|
+
lines = [float(line.split()[2]) for line in lines if (not 'dE' in line) and (not 'F=' in line)]
|
|
58
|
+
return np.array(lines[-nsteps:]) # as many last steps
|
|
54
59
|
|
|
55
60
|
return float(line.split('=')[1].split()[0])
|
|
56
61
|
|
|
@@ -15,6 +15,7 @@ import io
|
|
|
15
15
|
from contextlib import contextmanager
|
|
16
16
|
from pathlib import Path
|
|
17
17
|
from inspect import signature, getdoc
|
|
18
|
+
from itertools import islice
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
import numpy as np
|
|
@@ -36,17 +37,22 @@ def get_file_size(path: str):
|
|
|
36
37
|
else:
|
|
37
38
|
return ""
|
|
38
39
|
|
|
39
|
-
def take(f, rows, cols=None, dtype=
|
|
40
|
-
"""Read data from an opened file pointer `f` by indexing. Negative indexing is supported to read lines from end.
|
|
40
|
+
def take(f, rows, cols=None, dtype=None, exclude=None,sep=None):
|
|
41
|
+
"""Read data from an opened file pointer `f` by indexing. `rows=None` picks all lines. Negative indexing is supported to read lines from end.
|
|
41
42
|
Negative indexing is not supported in cols because of variable length of each line.
|
|
42
43
|
If `cols=None`, returns a single str of line if one integer given, otherwise a list of lines.
|
|
43
44
|
If `cols` is int ot sequence of int, each line is splitted by `sep` (default all whitespaces) and `dtype` is applied over resulting fields.
|
|
45
|
+
`exclude` should be regex. It removes matching lines after selection by `rows`. Empty lines are also discarded if `cols` is given.
|
|
46
|
+
|
|
47
|
+
Returns list (nested or plain) or single value or None based on `rows` and `cols` selection.
|
|
44
48
|
|
|
45
49
|
`take(f, -1, 1, float) == float(f.readlines()[-1].split()[1])` with advantage for consuming almost no memory as compared to `f.readlines()` on a huge file.
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
.. note::
|
|
52
|
+
For more robust reading of structured files like `PROCAR` use `ipyvasp.parse_text` function.
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
.. tip::
|
|
55
|
+
If your output is matrix-like, you can cast it to numpy array like `take(...)*np.array(1)`.
|
|
50
56
|
|
|
51
57
|
>>> with open('some_file','r') as f:
|
|
52
58
|
>>> take(f, -1, 1, float) # read last line, second column as float
|
|
@@ -61,20 +67,27 @@ def take(f, rows, cols=None, dtype=str, sep=None):
|
|
|
61
67
|
rows = [rows]
|
|
62
68
|
return_line = True
|
|
63
69
|
|
|
64
|
-
if not isinstance(rows, (tuple,list, range)):
|
|
70
|
+
if rows and not isinstance(rows, (tuple,list, range)):
|
|
65
71
|
raise TypeError(f"rows should int/list/tuple/range, got {type(rows)}")
|
|
66
72
|
|
|
67
73
|
f.seek(0)
|
|
68
|
-
if min(rows) < 0:
|
|
74
|
+
if rows and min(rows) < 0:
|
|
69
75
|
if not hasattr(f, '_nlines'): # do this once, assuming file is not changed while reading
|
|
70
76
|
f._nlines = sum(1 for _ in enumerate(f))
|
|
71
77
|
f.seek(0)
|
|
72
78
|
|
|
73
79
|
rows = [i + (f._nlines if i < 0 else 0) for i in rows] # make all positive
|
|
74
80
|
|
|
75
|
-
|
|
81
|
+
if rows is None:
|
|
82
|
+
lines = islice(f, None)
|
|
83
|
+
else:
|
|
84
|
+
lines = (l for i, l in enumerate(f) if i in rows)
|
|
76
85
|
|
|
77
|
-
if
|
|
86
|
+
if exclude:
|
|
87
|
+
lines = (l for l in lines if not re.search(exclude,l))
|
|
88
|
+
|
|
89
|
+
if cols is not None:
|
|
90
|
+
conv = dtype if callable(dtype) else (lambda v: v)
|
|
78
91
|
return_col = False
|
|
79
92
|
if isinstance(cols, int):
|
|
80
93
|
cols = [cols]
|
|
@@ -83,12 +96,16 @@ def take(f, rows, cols=None, dtype=str, sep=None):
|
|
|
83
96
|
if not isinstance(cols, (list,tuple, range)):
|
|
84
97
|
raise TypeError(f"cols should be a sequce of integers or single int, got {type(cols)}")
|
|
85
98
|
|
|
86
|
-
lines =
|
|
99
|
+
lines = (l for l in lines if l.strip()) # remove empty lines after indexing and only if cols are given
|
|
100
|
+
lines = ([conv(v) for i, v in enumerate(l.split(sep)) if i in cols] for l in lines)
|
|
87
101
|
|
|
88
102
|
if return_col:
|
|
89
|
-
lines =
|
|
103
|
+
lines = (line[0] if line else None for line in lines)
|
|
104
|
+
else:
|
|
105
|
+
return ''.join(lines) or None # just raw format as it is
|
|
90
106
|
|
|
91
|
-
return
|
|
107
|
+
# Try to return None where there is nothing
|
|
108
|
+
return next(lines,None) if return_line else (list(lines) or None)
|
|
92
109
|
|
|
93
110
|
|
|
94
111
|
def _sig_kwargs(from_func, skip_params=()):
|
|
@@ -261,10 +261,10 @@ class Files:
|
|
|
261
261
|
If you don't need to interpret the result of the function call, you can use the @self.interact decorator instead.
|
|
262
262
|
"""
|
|
263
263
|
info = ipw.HTML().add_class("fprogess")
|
|
264
|
-
dd = Dropdown(description='File', options=['
|
|
264
|
+
dd = Dropdown(description='File', options=['',*self._files]) # allows single file workable
|
|
265
265
|
|
|
266
266
|
def interact_func(fname, **kws):
|
|
267
|
-
if fname and str(fname) != '
|
|
267
|
+
if fname and str(fname) != '': # This would be None if no file is selected
|
|
268
268
|
info.value = _progress_svg
|
|
269
269
|
try:
|
|
270
270
|
start = time()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.9.87"
|
|
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
|
|
File without changes
|
|
File without changes
|