ipyvasp 0.9.4__py2.py3-none-any.whl → 0.9.5__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/_version.py +1 -1
- ipyvasp/widgets.py +37 -20
- {ipyvasp-0.9.4.dist-info → ipyvasp-0.9.5.dist-info}/METADATA +1 -1
- {ipyvasp-0.9.4.dist-info → ipyvasp-0.9.5.dist-info}/RECORD +8 -8
- {ipyvasp-0.9.4.dist-info → ipyvasp-0.9.5.dist-info}/LICENSE +0 -0
- {ipyvasp-0.9.4.dist-info → ipyvasp-0.9.5.dist-info}/WHEEL +0 -0
- {ipyvasp-0.9.4.dist-info → ipyvasp-0.9.5.dist-info}/entry_points.txt +0 -0
- {ipyvasp-0.9.4.dist-info → ipyvasp-0.9.5.dist-info}/top_level.txt +0 -0
ipyvasp/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.9.
|
|
1
|
+
__version__ = "0.9.5"
|
ipyvasp/widgets.py
CHANGED
|
@@ -106,12 +106,14 @@ class Files:
|
|
|
106
106
|
Parameters
|
|
107
107
|
----------
|
|
108
108
|
path_or_files : str, current directory by default or list of files or an instance of Files.
|
|
109
|
-
glob : str, glob pattern, '*' by default. Not used if files supplied above.
|
|
109
|
+
glob : str, glob pattern, '*' by default. '**' is used for recursive glob. Not used if files supplied above.
|
|
110
110
|
exclude : str, regular expression pattern to exclude files.
|
|
111
111
|
files_only : bool, if True, returns only files.
|
|
112
112
|
dirs_only : bool, if True, returns only directories.
|
|
113
113
|
|
|
114
114
|
Use methods on return such as `summarize`, `with_name`, `filtered`, `interact` and others.
|
|
115
|
+
|
|
116
|
+
>>> Files(root_1, glob_1,...).add(root_2, glob_2,...) # Fully flexible to chain
|
|
115
117
|
"""
|
|
116
118
|
def __init__(self, path_or_files = '.', glob = '*', exclude = None,files_only = False, dirs_only=False):
|
|
117
119
|
if isinstance(path_or_files, Files):
|
|
@@ -123,8 +125,7 @@ class Files:
|
|
|
123
125
|
|
|
124
126
|
files = []
|
|
125
127
|
if isinstance(path_or_files,(str, Path)):
|
|
126
|
-
|
|
127
|
-
files = [p for p in path.glob(glob)]
|
|
128
|
+
files = Path(path_or_files).glob(glob)
|
|
128
129
|
else:
|
|
129
130
|
others = []
|
|
130
131
|
for item in path_or_files:
|
|
@@ -142,23 +143,30 @@ class Files:
|
|
|
142
143
|
print(f"Skipping paths that do not exist: {list(set(others))}")
|
|
143
144
|
|
|
144
145
|
if exclude:
|
|
145
|
-
files =
|
|
146
|
+
files = (p for p in files if not re.search(exclude, str(p)))
|
|
146
147
|
if files_only:
|
|
147
|
-
files =
|
|
148
|
+
files = (p for p in files if p.is_file())
|
|
148
149
|
if dirs_only:
|
|
149
|
-
files =
|
|
150
|
+
files = (p for p in files if p.is_dir())
|
|
150
151
|
|
|
151
152
|
self._files = tuple(sorted(files))
|
|
152
153
|
|
|
154
|
+
def __str__(self):
|
|
155
|
+
return '\n'.join(str(f) for f in self._files)
|
|
156
|
+
|
|
153
157
|
def __repr__(self):
|
|
154
158
|
if not self: return "Files()"
|
|
155
|
-
|
|
159
|
+
show = ',\n'.join(f' {f!r}' for f in self._files)
|
|
160
|
+
return f"Files(\n{show}\n) {len(self._files)} items"
|
|
156
161
|
|
|
157
162
|
def __getitem__(self, index): return self._files[index]
|
|
158
163
|
def __iter__(self): return self._files.__iter__()
|
|
159
164
|
def __len__(self): return len(self._files)
|
|
160
165
|
def __bool__(self): return bool(self._files)
|
|
161
166
|
|
|
167
|
+
def __add__(self, other):
|
|
168
|
+
raise NotImplementedError("Use self.add method instead!")
|
|
169
|
+
|
|
162
170
|
def map(self,func):
|
|
163
171
|
"Map files to a function!"
|
|
164
172
|
return map(func, self._files)
|
|
@@ -199,15 +207,30 @@ class Files:
|
|
|
199
207
|
|
|
200
208
|
return self.with_name('POSCAR').summarize(info, tags=tags)
|
|
201
209
|
|
|
202
|
-
def update(self, path_or_files, glob = '*',**kwargs):
|
|
203
|
-
"Update files inplace with similar parameters as initialization.
|
|
204
|
-
|
|
210
|
+
def update(self, path_or_files, glob = '*', cleanup = True, exclude=None,**kwargs):
|
|
211
|
+
"""Update files inplace with similar parameters as initialization. If `cleanup=False`, older files are kept too.
|
|
212
|
+
Useful for widgets such as BandsWidget to preserve their state while using `widget.files.update`."""
|
|
213
|
+
old = () if cleanup else self._files
|
|
214
|
+
self._files = self._unique(old, self.__class__(path_or_files, glob = glob, exclude=exclude,**kwargs)._files)
|
|
215
|
+
|
|
205
216
|
if (dd := getattr(self, '_dd', None)): # update dropdown
|
|
206
217
|
old = dd.value
|
|
207
218
|
dd.options = self._files
|
|
208
219
|
if old in dd.options:
|
|
209
220
|
dd.value = old
|
|
210
221
|
|
|
222
|
+
def add(self, path_or_files, glob = '*', exclude=None, **kwargs):
|
|
223
|
+
"""Add more files or with a diffrent glob on top of exitsing files. Returns same instance.
|
|
224
|
+
Useful to add multiple globbed files into a single chained call.
|
|
225
|
+
|
|
226
|
+
>>> Files(root_1, glob_1,...).add(root_2, glob_2,...) # Fully flexible
|
|
227
|
+
"""
|
|
228
|
+
self._files = self._unique(self._files, self.__class__(path_or_files, glob = glob, exclude=exclude,**kwargs)._files)
|
|
229
|
+
return self
|
|
230
|
+
|
|
231
|
+
def _unique(self, *files_tuples):
|
|
232
|
+
return tuple(np.unique(np.hstack(files_tuples)))
|
|
233
|
+
|
|
211
234
|
def interactive(self, func, *args,
|
|
212
235
|
free_widgets=None,
|
|
213
236
|
options={"manual": False},
|
|
@@ -320,16 +343,10 @@ class Files:
|
|
|
320
343
|
] # add hr to separate other controls
|
|
321
344
|
|
|
322
345
|
out.children = [
|
|
323
|
-
HBox(
|
|
324
|
-
[ #
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
), # other widgets in box to make scrollable independent file selection
|
|
328
|
-
VBox(
|
|
329
|
-
children=[output, *args, info]
|
|
330
|
-
), # output in box to make scrollable,
|
|
331
|
-
],
|
|
332
|
-
layout=Layout(height=height, max_height=height),
|
|
346
|
+
HBox([ # reset children to include new widgets
|
|
347
|
+
VBox([dd, VBox(others)]), # other widgets in box to make scrollable independent file selection
|
|
348
|
+
VBox([Box([output]), *args, info]), # output in box to make scrollable,
|
|
349
|
+
],layout=Layout(height=height, max_height=height),
|
|
333
350
|
).add_class("files-interact")
|
|
334
351
|
] # important for every widget separately
|
|
335
352
|
return out
|
|
@@ -2,7 +2,7 @@ ipyvasp/__init__.py,sha256=rlorju9arMtHw1QRYPljday-PyZWJdSCxg4lw3g6t0Q,1409
|
|
|
2
2
|
ipyvasp/__main__.py,sha256=eJV1TZSiT8mC_VqAeksNnBI2I8mKMiPkEIlwikbtOjI,216
|
|
3
3
|
ipyvasp/_enplots.py,sha256=D38paN8zqZgluNAwmCwcocd7-_h_T0HTGolI1eBkDes,37484
|
|
4
4
|
ipyvasp/_lattice.py,sha256=GxG0C4lwVGvBYIy3jwR1kahWR7L6kJlqjIiQGgESjcM,104135
|
|
5
|
-
ipyvasp/_version.py,sha256=
|
|
5
|
+
ipyvasp/_version.py,sha256=UvB3IZAWAs7vV6H9dpZvZPryrSNIyF5_bowVS4_YGFA,23
|
|
6
6
|
ipyvasp/bsdos.py,sha256=1rG68S-dLEYveIWGK7r8CRa7Qqlqno0l1ncfo2ocihk,30424
|
|
7
7
|
ipyvasp/cli.py,sha256=aWFEVhNmnW8eSOp5uh95JaDwLQ9K9nlCQcbnOSuhWgw,6844
|
|
8
8
|
ipyvasp/evals_dataframe.py,sha256=-sqxK7LPV6sYDO_XXmZ80FznOaXTkVdbqJKKvTUtMak,20637
|
|
@@ -11,15 +11,15 @@ ipyvasp/misc.py,sha256=SZJ_ePUR2-HEKYTEpDHVRVE7zpIQVTCjiuw0BCC9UTU,2349
|
|
|
11
11
|
ipyvasp/potential.py,sha256=tzA73c5lkp6ahLSJchMrU043-QWaOV0nIOUA7VMmfKQ,11408
|
|
12
12
|
ipyvasp/surface.py,sha256=MjE5oB0wW6Pca_C-xu8rN6OMH7lUEeNPNyM7Kz_Im-8,23766
|
|
13
13
|
ipyvasp/utils.py,sha256=rVyD5SkO_Y7ok5W-fJeQys9X8pLLbDK7VOgbAbcE4WU,14227
|
|
14
|
-
ipyvasp/widgets.py,sha256=
|
|
14
|
+
ipyvasp/widgets.py,sha256=hwCviQn5NmxFz15DTS2nKKJ0kdBq8taGude46KNDOtU,46605
|
|
15
15
|
ipyvasp/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
ipyvasp/core/parser.py,sha256=C3CaZsJbPME_ttYlYy4DXeOdL7dnkXs-cHRwFZL6bio,38058
|
|
17
17
|
ipyvasp/core/plot_toolkit.py,sha256=3RoPsND5gPssBSfS5H4TjoZ2Qz7B97vpxeKadc2cRRs,36046
|
|
18
18
|
ipyvasp/core/serializer.py,sha256=XpqnfVGsUXiN2CuVRPyqsSVouxRBO-UH6AnsHnPYvZY,36729
|
|
19
19
|
ipyvasp/core/spatial_toolkit.py,sha256=8DBYTiBFWJ7OBKuvOPw7UoEVCyNjJhSW0OcudjYZvAw,14748
|
|
20
|
-
ipyvasp-0.9.
|
|
21
|
-
ipyvasp-0.9.
|
|
22
|
-
ipyvasp-0.9.
|
|
23
|
-
ipyvasp-0.9.
|
|
24
|
-
ipyvasp-0.9.
|
|
25
|
-
ipyvasp-0.9.
|
|
20
|
+
ipyvasp-0.9.5.dist-info/LICENSE,sha256=F3SO5RiAZOMfmMGf1KOuk2g_c4ObvuBJhd9iBLDgXoQ,1263
|
|
21
|
+
ipyvasp-0.9.5.dist-info/METADATA,sha256=Vfq6b9vA2i5LjHBcUTb8KkXkkCK3jldhXPNUm27MvsQ,2420
|
|
22
|
+
ipyvasp-0.9.5.dist-info/WHEEL,sha256=iYlv5fX357PQyRT2o6tw1bN-YcKFFHKqB_LwHO5wP-g,110
|
|
23
|
+
ipyvasp-0.9.5.dist-info/entry_points.txt,sha256=C7m0Sjmr14wFjflCkWXLzr5N6-cQj8uJC9n82mUtzt8,44
|
|
24
|
+
ipyvasp-0.9.5.dist-info/top_level.txt,sha256=ftziWlMWu_1VpDP1sRTFrkfBnWxAi393HYDVu4wRhUk,8
|
|
25
|
+
ipyvasp-0.9.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|