mirror of
https://github.com/triqs/dft_tools
synced 2024-12-22 04:13:47 +01:00
Added a small test suite for 'c_plocar_io' module
This commit is contained in:
parent
19a30034f5
commit
7e894d98f6
@ -1,7 +1,7 @@
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
|
||||
//#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
|
||||
|
||||
#include <numpy/arrayobject.h>
|
||||
#include <complex.h>
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
#define MAX_STR_LEN 512
|
||||
|
||||
static int verbose = 1;
|
||||
static int verbose = 0;
|
||||
|
||||
typedef struct {
|
||||
int nion;
|
||||
@ -76,7 +76,7 @@ io_read_plocar(PyObject *self, PyObject *args)
|
||||
fh = fopen(fname, "r");
|
||||
if(fh == NULL) {
|
||||
// Treat this error separately because no clean-up is necessary
|
||||
strncpy(errmsg, "Error opening PLOCAR\n", MAX_STR_LEN);
|
||||
snprintf(errmsg, MAX_STR_LEN, "Error opening %s\n", fname);
|
||||
strncat(errmsg, strerror(errno), MAX_STR_LEN);
|
||||
PyErr_SetString(PyExc_IOError, errmsg);
|
||||
return NULL;
|
||||
@ -162,13 +162,12 @@ io_read_plocar(PyObject *self, PyObject *args)
|
||||
// Handle IO-errors
|
||||
//
|
||||
ioerror:
|
||||
printf("Error number: %d\n", errno);
|
||||
if(feof(fh)) {
|
||||
PyErr_SetString(PyExc_IOError, "End-of-file reading PLOCAR");
|
||||
snprintf(errmsg, MAX_STR_LEN, "End-of-file reading %s", fname);
|
||||
PyErr_SetString(PyExc_IOError, errmsg);
|
||||
}
|
||||
else {
|
||||
strncpy(errmsg, "Error reading PLOCAR\n", MAX_STR_LEN);
|
||||
strncat(errmsg, strerror(errno), MAX_STR_LEN);
|
||||
snprintf(errmsg, MAX_STR_LEN, "Error reading %s: %s", fname, strerror(errno));
|
||||
PyErr_SetString(PyExc_IOError, errmsg);
|
||||
}
|
||||
|
||||
|
2
python/converters/vasp/test/plocar_io/.gitignore
vendored
Normal file
2
python/converters/vasp/test/plocar_io/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.pyc
|
||||
*.test
|
BIN
python/converters/vasp/test/plocar_io/PLOCAR.example
Normal file
BIN
python/converters/vasp/test/plocar_io/PLOCAR.example
Normal file
Binary file not shown.
2401
python/converters/vasp/test/plocar_io/PLOCAR.example.out
Normal file
2401
python/converters/vasp/test/plocar_io/PLOCAR.example.out
Normal file
File diff suppressed because it is too large
Load Diff
259
python/converters/vasp/test/plocar_io/PLOCAR.noprec
Normal file
259
python/converters/vasp/test/plocar_io/PLOCAR.noprec
Normal file
@ -0,0 +1,259 @@
|
||||
0000000: 0700 0000 0100 0000 0100 0000 0300 0000 ................
|
||||
0000010: 0900 0000 0900 0000 0000 0000 0900 0000 ................
|
||||
0000020: 0000 0000 0000 0040 c09b 42b4 952c 303e .......@..B..,0>
|
||||
0000030: 0000 0000 0000 0000 876a f460 f6ec d93f .........j.`...?
|
||||
0000040: 0000 0000 0000 0000 80ab 01a5 b7c9 d93f ...............?
|
||||
0000050: 0000 0000 0000 0000 dc82 5188 ebf7 d93f ..........Q....?
|
||||
0000060: 0000 0000 0000 0000 389e aae4 5c59 a4be ........8...\Y..
|
||||
0000070: 0000 0000 0000 0000 f0cb ad9d 48d2 9bbe ............H...
|
||||
0000080: 0000 0000 0000 0000 08ee b871 1214 773e ...........q..w>
|
||||
0000090: 0000 0000 0000 0000 5095 ab03 b4cc 99be ........P.......
|
||||
00000a0: 0000 0000 0000 0000 00e2 0cec 4018 8e3e ............@..>
|
||||
00000b0: 0000 0000 0000 0000 0000 0000 0000 0040 ...............@
|
||||
00000c0: 68c3 e962 e8c3 42be 0000 0000 0000 0000 h..b..B.........
|
||||
00000d0: c907 d02d 79b5 c83f 0000 0000 0000 0000 ...-y..?........
|
||||
00000e0: 6d5c b47d afec e4bf 0000 0000 0000 0000 m\.}............
|
||||
00000f0: 8871 d914 bb3d dd3f 0000 0000 0000 0000 .q...=.?........
|
||||
0000100: a09e cab7 fba1 99be 0000 0000 0000 0000 ................
|
||||
0000110: 1011 02ea 4ed4 a5be 0000 0000 0000 0000 ....N...........
|
||||
0000120: b8bd 64b5 faea a5be 0000 0000 0000 0000 ..d.............
|
||||
0000130: 98d6 110d 5dec 733e 0000 0000 0000 0000 ....].s>........
|
||||
0000140: 20bf c505 81ca 953e 0000 0000 0000 0000 ......>........
|
||||
0000150: 0000 0000 0000 0040 5ede f7c4 28c9 513e .......@^...(.Q>
|
||||
0000160: 0000 0000 0000 0000 5f10 eece 9bc5 e7bf ........_.......
|
||||
0000170: 0000 0000 0000 0000 c756 8fc2 d323 bc3f .........V...#.?
|
||||
0000180: 0000 0000 0000 0000 6226 1a03 4747 e43f ........b&..GG.?
|
||||
0000190: 0000 0000 0000 0000 88cf 411b faee b23e ..........A....>
|
||||
00001a0: 0000 0000 0000 0000 d059 0ef7 3322 bc3e .........Y..3".>
|
||||
00001b0: 0000 0000 0000 0000 906f ecbd 13bf 9b3e .........o.....>
|
||||
00001c0: 0000 0000 0000 0000 0048 dc80 c623 79be .........H...#y.
|
||||
00001d0: 0000 0000 0000 0000 98af a7f0 cc0a 80be ................
|
||||
00001e0: 0000 0000 0000 0000 0000 0000 0000 0040 ...............@
|
||||
00001f0: 7732 c238 fc5d d4bf 0000 0000 0000 0000 w2.8.]..........
|
||||
0000200: af10 22fe 0157 1e3e 0000 0000 0000 0000 .."..W.>........
|
||||
0000210: b6f2 3804 5f94 19be 0000 0000 0000 0000 ..8._...........
|
||||
0000220: f3fa 220d f74a 10be 0000 0000 0000 0000 .."..J..........
|
||||
0000230: 9050 2512 1143 713e 0000 0000 0000 0000 .P%..Cq>........
|
||||
0000240: 70d3 c7a3 9414 713e 0000 0000 0000 0000 p.....q>........
|
||||
0000250: 102c bb6e a8fd 123e 0000 0000 0000 0000 .,.n...>........
|
||||
0000260: 8804 1ca7 2cef 703e 0000 0000 0000 0000 ....,.p>........
|
||||
0000270: 00e7 3a91 6f8c 0b3e 0000 0000 0000 0000 ..:.o..>........
|
||||
0000280: 0000 0000 0000 0040 f494 55cd 093c abbe .......@..U..<..
|
||||
0000290: 0000 0000 0000 0000 9368 0c94 3992 b5be .........h..9...
|
||||
00002a0: 0000 0000 0000 0000 31db 0ceb 4592 b13e ........1...E..>
|
||||
00002b0: 0000 0000 0000 0000 4a33 08f3 8b2f aa3e ........J3.../.>
|
||||
00002c0: 0000 0000 0000 0000 4bd8 9f87 3736 d5bf ........K...76..
|
||||
00002d0: 0000 0000 0000 0000 d028 1b47 86da d5bf .........(.G....
|
||||
00002e0: 0000 0000 0000 0000 7983 970b 9a0a 10be ........y.......
|
||||
00002f0: 0000 0000 0000 0000 3d51 3b73 82d8 d5bf ........=Q;s....
|
||||
0000300: 0000 0000 0000 0000 5ee2 3953 96be eabd ........^.9S....
|
||||
0000310: 0000 0000 0000 0000 0000 0000 0000 0040 ...............@
|
||||
0000320: e02d e04c 16cc a3be 0000 0000 0000 0000 .-.L............
|
||||
0000330: 45d9 4cd2 8e29 a1be 0000 0000 0000 0000 E.L..)..........
|
||||
0000340: a6be 872b d81d aebe 0000 0000 0000 0000 ...+............
|
||||
0000350: 6261 dc48 428c a5be 0000 0000 0000 0000 ba.HB...........
|
||||
0000360: 4e2b 9eaa 4723 e13f 0000 0000 0000 0000 N+..G#.?........
|
||||
0000370: 7dab 254c f2bb d0bf 0000 0000 0000 0000 }.%L............
|
||||
0000380: 3614 5bd6 5785 77be 0000 0000 0000 0000 6.[.W.w.........
|
||||
0000390: dc11 2b1c 7a8f d0bf 0000 0000 0000 0000 ..+.z...........
|
||||
00003a0: bacd a52a 3e27 f33d 0000 0000 0000 0000 ...*>'.=........
|
||||
00003b0: 0000 0000 0000 0040 3ec2 a914 b349 953e .......@>....I.>
|
||||
00003c0: 0000 0000 0000 0000 e1e1 30f2 ec27 b1be ..........0..'..
|
||||
00003d0: 0000 0000 0000 0000 f9fa cf80 b262 a33e .............b.>
|
||||
00003e0: 0000 0000 0000 0000 c30d 0bea fff7 b03e ...............>
|
||||
00003f0: 0000 0000 0000 0000 ddb7 83f6 7181 5fbf ............q._.
|
||||
0000400: 0000 0000 0000 0000 7cb5 f3a7 1dde e2bf ........|.......
|
||||
0000410: 0000 0000 0000 0000 04ec d82c 5973 f73d ...........,Ys.=
|
||||
0000420: 0000 0000 0000 0000 2589 b733 caef e23f ........%..3...?
|
||||
0000430: 0000 0000 0000 0000 b680 c91e 7c87 7e3e ............|.~>
|
||||
0000440: 0000 0000 0000 0000 8399 6cf2 a7a8 733a ..........l...s:
|
||||
0000450: a226 c082 8d99 a2be 0000 0000 0000 0000 .&..............
|
||||
0000460: 4f75 9af5 f751 88be 0000 0000 0000 0000 Ou...Q..........
|
||||
0000470: c87f 8c77 6f11 8c3e 0000 0000 0000 0000 ...wo..>........
|
||||
0000480: 634e 55db dffe 88be 0000 0000 0000 0000 cNU.............
|
||||
0000490: b9a2 7a78 99f2 33be 0000 0000 0000 0000 ..zx..3.........
|
||||
00004a0: 6232 6dee 00ec 763e 0000 0000 0000 0000 b2m...v>........
|
||||
00004b0: 34f6 8e31 ebb1 a3bf 0000 0000 0000 0000 4..1............
|
||||
00004c0: b0e1 85b7 93be 75be 0000 0000 0000 0000 ......u.........
|
||||
00004d0: fca1 4ac0 516b ea3f 0000 0000 0000 0000 ..J.Qk.?........
|
||||
00004e0: ead9 7db9 a7a8 733a 2051 d326 ab04 b63e ..}...s: Q.&...>
|
||||
00004f0: 0000 0000 0000 0000 a664 a63a b204 a6be .........d.:....
|
||||
0000500: 0000 0000 0000 0000 9a14 a1cc cd1a ad3e ...............>
|
||||
0000510: 0000 0000 0000 0000 c317 f9d9 0bc9 763e ..............v>
|
||||
0000520: 0000 0000 0000 0000 1a6c 522f 33ef 73be .........lR/3.s.
|
||||
0000530: 0000 0000 0000 0000 0e69 5a77 ef3f 613e .........iZw.?a>
|
||||
0000540: 0000 0000 0000 0000 83d3 00cf 74a4 e4bf ............t...
|
||||
0000550: 0000 0000 0000 0000 e0c9 1246 8398 663e ...........F..f>
|
||||
0000560: 0000 0000 0000 0000 df05 97c4 fdcd a8bf ................
|
||||
0000570: 0000 0000 0000 0000 0000 0000 0000 0040 ...............@
|
||||
0000580: 5865 652e d78d 543e 0000 0000 0000 0000 Xee...T>........
|
||||
0000590: e287 40f4 d20f e63f 0000 0000 0000 0000 ..@....?........
|
||||
00005a0: 6015 14f3 d20f e63f 0000 0000 0000 0000 `......?........
|
||||
00005b0: 1f46 1b02 2ad0 953e 0000 0000 0000 0000 .F..*..>........
|
||||
00005c0: a896 501e cc76 adbe 0000 0000 0000 0000 ..P..v..........
|
||||
00005d0: 50e1 ce66 d74e a9be 0000 0000 0000 0000 P..f.N..........
|
||||
00005e0: 68c6 cb41 12c4 94be 0000 0000 0000 0000 h..A............
|
||||
00005f0: b8b6 a59a 2725 b03e 0000 0000 0000 0000 ....'%.>........
|
||||
0000600: 000c e03e d4e6 723e 0000 0000 0000 0000 ...>..r>........
|
||||
0000610: 0000 0000 0000 0040 5034 3525 9915 1d3e .......@P45%...>
|
||||
0000620: 0000 0000 0000 0000 0eb1 b04c a169 8b3e ...........L.i.>
|
||||
0000630: 0000 0000 0000 0000 15a6 44c3 d2bb 8c3e ..........D....>
|
||||
0000640: 0000 0000 0000 0000 358d 6630 0564 edbf ........5.f0.d..
|
||||
0000650: 0000 0000 0000 0000 f093 7bd3 66dd a93e ..........{.f..>
|
||||
0000660: 0000 0000 0000 0000 300e e949 11a8 7d3e ........0..I..}>
|
||||
0000670: 0000 0000 0000 0000 4e4d eb99 4625 69be ........NM..F%i.
|
||||
0000680: 0000 0000 0000 0000 7065 6266 62dd aabe ........pebfb...
|
||||
0000690: 0000 0000 0000 0000 7a8f 27f1 7c5e 653e ........z.'.|^e>
|
||||
00006a0: 0000 0000 0000 0000 0000 0000 0000 0040 ...............@
|
||||
00006b0: 86a7 8f83 5c29 64be 0000 0000 0000 0000 ....\)d.........
|
||||
00006c0: 6105 908f 5ec9 e23f 0000 0000 0000 0000 a...^..?........
|
||||
00006d0: 3010 7490 5ec9 e2bf 0000 0000 0000 0000 0.t.^...........
|
||||
00006e0: f3a7 bf6b 3ebc 39be 0000 0000 0000 0000 ...k>.9.........
|
||||
00006f0: a054 44ce 55ef 573e 0000 0000 0000 0000 .TD.U.W>........
|
||||
0000700: 3061 3567 33aa a53e 0000 0000 0000 0000 0a5g3..>........
|
||||
0000710: 2024 2b9b e650 843e 0000 0000 0000 0000 $+..P.>........
|
||||
0000720: d8a7 4cf5 ad7e 6abe 0000 0000 0000 0000 ..L..~j.........
|
||||
0000730: d869 203f 9533 a2be 0000 0000 0000 0000 .i ?.3..........
|
||||
0000740: 0000 0000 0000 0040 6bf4 6d7e 31b5 b03f .......@k.m~1..?
|
||||
0000750: 0000 0000 0000 0000 3219 ab9d 1f41 96be ........2....A..
|
||||
0000760: 0000 0000 0000 0000 b926 d998 ffe0 9f3e .........&.....>
|
||||
0000770: 0000 0000 0000 0000 c77d 8dee 2ae1 b83e .........}..*..>
|
||||
0000780: 0000 0000 0000 0000 7076 1727 a6a1 653e ........pv.'..e>
|
||||
0000790: 0000 0000 0000 0000 c8e3 69f1 3f54 cbbf ..........i.?T..
|
||||
00007a0: 0000 0000 0000 0000 bc51 aadf 8db5 b4bf .........Q......
|
||||
00007b0: 0000 0000 0000 0000 8421 5e6d b864 653e .........!^m.de>
|
||||
00007c0: 0000 0000 0000 0000 a45c 97d6 47ef c13f .........\..G..?
|
||||
00007d0: 0000 0000 0000 0000 0000 0000 0000 0040 ...............@
|
||||
00007e0: 580c fc1b 6050 b43e 0000 0000 0000 0000 X...`P.>........
|
||||
00007f0: e1dd 2899 963d b9be 0000 0000 0000 0000 ..(..=..........
|
||||
0000800: f098 804f 9cee babe 0000 0000 0000 0000 ...O............
|
||||
0000810: bbba a80f 6b53 9c3e 0000 0000 0000 0000 ....kS.>........
|
||||
0000820: cdc5 748c 3631 e0bf 0000 0000 0000 0000 ..t.61..........
|
||||
0000830: 2af0 1da2 580a a13e 0000 0000 0000 0000 *...X..>........
|
||||
0000840: f85a ee26 9852 843e 0000 0000 0000 0000 .Z.&.R.>........
|
||||
0000850: 31c5 468c 3631 e03f 0000 0000 0000 0000 1.F.61.?........
|
||||
0000860: 9299 7dec f414 86be 0000 0000 0000 0000 ..}.............
|
||||
0000870: 822f 4855 5555 e53f 028b fb0b 3c8e 67be ./HUUU.?....<.g.
|
||||
0000880: 0000 0000 0000 0000 e6de 49e1 241d a63f ..........I.$..?
|
||||
0000890: 0000 0000 0000 0000 fa1c 05de 241d a63f ............$..?
|
||||
00008a0: 0000 0000 0000 0000 34d5 928c b580 34be ........4.....4.
|
||||
00008b0: 0000 0000 0000 0000 00d6 8b99 0461 023e .............a.>
|
||||
00008c0: 0000 0000 0000 0000 be96 7d4c 60c9 5dbe ..........}L`.].
|
||||
00008d0: 0000 0000 0000 0000 c03e 78c4 5826 42be .........>x.X&B.
|
||||
00008e0: 0000 0000 0000 0000 0020 b091 40d5 21be ......... ..@.!.
|
||||
00008f0: 0000 0000 0000 0000 8092 f420 8b45 293e ........... .E)>
|
||||
0000900: 0000 0000 0000 0000 2e74 7c22 caad df39 .........t|"...9
|
||||
0000910: 9135 b7cd 1aca 98bf 0000 0000 0000 0000 .5..............
|
||||
0000920: 6b78 558f e98a 953e 0000 0000 0000 0000 kxU....>........
|
||||
0000930: 5791 b997 d4a5 743e 0000 0000 0000 0000 W.....t>........
|
||||
0000940: 4d7a d5de d758 8abe 0000 0000 0000 0000 Mz...X..........
|
||||
0000950: c8eb 2725 a124 40be 0000 0000 0000 0000 ..'%.$@.........
|
||||
0000960: 0e7b 0b34 09a5 c83f 0000 0000 0000 0000 .{.4...?........
|
||||
0000970: 1374 66b3 dd45 c2bf 0000 0000 0000 0000 .tf..E..........
|
||||
0000980: 9cad bd36 5b30 4abe 0000 0000 0000 0000 ...6[0J.........
|
||||
0000990: 22ca 2329 4da6 cf3f 0000 0000 0000 0000 ".#)M..?........
|
||||
00009a0: a908 7df2 2a10 b633 4102 b43d f7df bf3e ..}.*..3A..=...>
|
||||
00009b0: 0000 0000 0000 0000 d321 5412 a30f 78be .........!T...x.
|
||||
00009c0: 0000 0000 0000 0000 be26 a002 bcdf 643e .........&....d>
|
||||
00009d0: 0000 0000 0000 0000 1a71 c094 33d1 6a3e .........q..3.j>
|
||||
00009e0: 0000 0000 0000 0000 d8c4 c761 63d6 3a3e ...........ac.:>
|
||||
00009f0: 0000 0000 0000 0000 f428 8c8f 9387 cb3e .........(.....>
|
||||
0000a00: 0000 0000 0000 0000 959c e520 beb6 afbf ........... ....
|
||||
0000a10: 0000 0000 0000 0000 5cac baff e1c3 3a3e ........\.....:>
|
||||
0000a20: 0000 0000 0000 0000 3604 e0c7 994f a2bf ........6....O..
|
||||
0000a30: 0000 0000 0000 0000 8081 c5a2 1f01 0000 ................
|
||||
0000a40: 28c4 2e02 16af 583e 0000 0000 0000 0000 (.....X>........
|
||||
0000a50: 0ffd a93a a81a 713e 0000 0000 0000 0000 ...:..q>........
|
||||
0000a60: 5e9a f9f0 614e 803e 0000 0000 0000 0000 ^...aN.>........
|
||||
0000a70: 82fc d823 ff71 673e 0000 0000 0000 0000 ...#.qg>........
|
||||
0000a80: 8a5f 1480 3d19 d2bf 0000 0000 0000 0000 ._..=...........
|
||||
0000a90: c0c4 bdfa 0b27 833e 0000 0000 0000 0000 .....'.>........
|
||||
0000aa0: 802d 5ea3 1560 653e 0000 0000 0000 0000 .-^..`e>........
|
||||
0000ab0: 7295 957f 3d19 d2bf 0000 0000 0000 0000 r...=...........
|
||||
0000ac0: 40fa 65d6 bd01 73be 0000 0000 0000 0000 @.e...s.........
|
||||
0000ad0: 0000 0000 0000 0040 4e7a c103 c082 c7bd .......@Nz......
|
||||
0000ae0: 0000 0000 0000 0000 fe64 e1e0 da19 afbf .........d......
|
||||
0000af0: 0000 0000 0000 0000 ddf4 52d5 f436 b0bf ..........R..6..
|
||||
0000b00: 0000 0000 0000 0000 e2d5 34c7 96bc afbf ..........4.....
|
||||
0000b10: 0000 0000 0000 0000 0017 aab8 55ff 70be ............U.p.
|
||||
0000b20: 0000 0000 0000 0000 589f c883 5b70 703e ........X...[pp>
|
||||
0000b30: 0000 0000 0000 0000 7039 f1f7 45b0 a23e ........p9..E..>
|
||||
0000b40: 0000 0000 0000 0000 88a2 4a66 36fa 613e ..........Jf6.a>
|
||||
0000b50: 0000 0000 0000 0000 3026 f8db ef44 99be ........0&...D..
|
||||
0000b60: 0000 0000 0000 0000 0000 0000 0000 0040 ...............@
|
||||
0000b70: 3ab1 0ba7 a58d d2bd 0000 0000 0000 0000 :...............
|
||||
0000b80: c804 25ad 7e1f d0bf 0000 0000 0000 0000 ..%.~...........
|
||||
0000b90: 4bbc 7b17 11ee d43f 0000 0000 0000 0000 K.{....?........
|
||||
0000ba0: 4057 bff4 a604 b3bf 0000 0000 0000 0000 @W..............
|
||||
0000bb0: 204f 5c0e 7187 5d3e 0000 0000 0000 0000 O\.q.]>........
|
||||
0000bc0: 6070 df46 86ab 61be 0000 0000 0000 0000 `p.F..a.........
|
||||
0000bd0: 40e4 5596 c4f6 b2be 0000 0000 0000 0000 @.U.............
|
||||
0000be0: 003e 6579 2fc2 463e 0000 0000 0000 0000 .>ey/.F>........
|
||||
0000bf0: 500b 4582 321f aa3e 0000 0000 0000 0000 P.E.2..>........
|
||||
0000c00: 0000 0000 0000 0040 06c8 13a4 8c3a a63d .......@.....:.=
|
||||
0000c10: 0000 0000 0000 0000 75d4 3257 e329 bb3f ........u.2W.).?
|
||||
0000c20: 0000 0000 0000 0000 9b49 12ad 2322 c43f .........I..#".?
|
||||
0000c30: 0000 0000 0000 0000 a2cc ac0f d9ca d0bf ................
|
||||
0000c40: 0000 0000 0000 0000 d8ec a498 2321 67be ............#!g.
|
||||
0000c50: 0000 0000 0000 0000 e8f4 36bb 3418 613e ..........6.4.a>
|
||||
0000c60: 0000 0000 0000 0000 e08d cf0e c0c9 913e ...............>
|
||||
0000c70: 0000 0000 0000 0000 f0c4 1ee7 d94e 4f3e .............NO>
|
||||
0000c80: 0000 0000 0000 0000 20a2 909f 5b09 78be ........ ...[.x.
|
||||
0000c90: 0000 0000 0000 0000 0000 0000 0000 0040 ...............@
|
||||
0000ca0: 2a69 653b ad47 11be 0000 0000 0000 0000 *ie;.G..........
|
||||
0000cb0: cede b402 68eb 463e 0000 0000 0000 0000 ....h.F>........
|
||||
0000cc0: 3870 f49b c4e9 42be 0000 0000 0000 0000 8p....B.........
|
||||
0000cd0: 7a5a 85f4 c17f 7dbe 0000 0000 0000 0000 zZ....}.........
|
||||
0000ce0: b4bd abe6 dea9 afbd 0000 0000 0000 0000 ................
|
||||
0000cf0: 303f 810e 3a8d 4d3e 0000 0000 0000 0000 0?..:.M>........
|
||||
0000d00: 56c1 caac 92eb 103f 0000 0000 0000 0000 V......?........
|
||||
0000d10: 90ea 6654 0d81 4dbe 0000 0000 0000 0000 ..fT..M.........
|
||||
0000d20: 64dc 70c8 7b05 e2bf 0000 0000 0000 0000 d.p.{...........
|
||||
0000d30: 0000 0000 0000 0040 881e 655a 1470 193e .......@..eZ.p.>
|
||||
0000d40: 0000 0000 0000 0000 5c83 cc86 f7c5 a0be ........\.......
|
||||
0000d50: 0000 0000 0000 0000 97ef ee3f c5d5 a43e ...........?...>
|
||||
0000d60: 0000 0000 0000 0000 68b0 b504 dde5 7a3e ........h.....z>
|
||||
0000d70: 0000 0000 0000 0000 2cba e388 789d 55be ........,...x.U.
|
||||
0000d80: 0000 0000 0000 0000 f8cf 5c01 9a90 453e ..........\...E>
|
||||
0000d90: 0000 0000 0000 0000 d030 93fe 8c13 e73f .........0.....?
|
||||
0000da0: 0000 0000 0000 0000 b035 f3eb 43a0 453e .........5..C.E>
|
||||
0000db0: 0000 0000 0000 0000 0c87 8334 9f14 093f ...........4...?
|
||||
0000dc0: 0000 0000 0000 0000 2401 9267 ed96 9e11 ........$..g....
|
||||
0000dd0: 1453 f0fd 5952 b1be 0000 0000 0000 0000 .S..YR..........
|
||||
0000de0: c09b f917 e482 733e 0000 0000 0000 0000 ......s>........
|
||||
0000df0: 38a0 a3a4 8b34 70be 0000 0000 0000 0000 8....4p.........
|
||||
0000e00: 9f13 40bf ee7c 953e 0000 0000 0000 0000 ..@..|.>........
|
||||
0000e10: c064 795f 3853 dcbf 0000 0000 0000 0000 .dy_8S..........
|
||||
0000e20: 82db 8bbd c448 e0bf 0000 0000 0000 0000 .....H..........
|
||||
0000e30: 00d9 583c 9511 13be 0000 0000 0000 0000 ..X<............
|
||||
0000e40: 7ed6 1219 5f6a e0bf 0000 0000 0000 0000 ~..._j..........
|
||||
0000e50: f062 5384 fbe4 4a3e 0000 0000 0000 0000 .bS...J>........
|
||||
0000e60: fca3 76c4 d096 9e11 56a9 ac12 fc7f 5b3e ..v.....V.....[>
|
||||
0000e70: 0000 0000 0000 0000 7479 84d6 0789 833e ........ty.....>
|
||||
0000e80: 0000 0000 0000 0000 6eab 07b9 1af0 73be ........n.....s.
|
||||
0000e90: 0000 0000 0000 0000 1d62 1157 7be7 69be .........b.W{.i.
|
||||
0000ea0: 0000 0000 0000 0000 70d4 0b85 7ebb e5bf ........p...~...
|
||||
0000eb0: 0000 0000 0000 0000 0e44 6738 50e2 ce3f .........Dg8P..?
|
||||
0000ec0: 0000 0000 0000 0000 a033 dbb1 7275 89be .........3..ru..
|
||||
0000ed0: 0000 0000 0000 0000 7a0a 264c 8815 d63f ........z.&L...?
|
||||
0000ee0: 0000 0000 0000 0000 48be 232f 416d 6dbe ........H.#/Amm.
|
||||
0000ef0: 0000 0000 0000 0000 6c89 eea2 ca96 9e11 ........l.......
|
||||
0000f00: d229 6415 ccd1 56be 0000 0000 0000 0000 .)d...V.........
|
||||
0000f10: c5e6 8a3b 6352 6d3e 0000 0000 0000 0000 ...;cRm>........
|
||||
0000f20: c006 0629 c7b9 61be 0000 0000 0000 0000 ...)..a.........
|
||||
0000f30: eb93 83ea 8a6e 873e 0000 0000 0000 0000 .....n.>........
|
||||
0000f40: 5e7e cd97 e492 a2bf 0000 0000 0000 0000 ^~..............
|
||||
0000f50: 66b4 4e2e c8c7 df3f 0000 0000 0000 0000 f.N....?........
|
||||
0000f60: 20b1 e909 b146 6bbe 0000 0000 0000 0000 ....Fk.........
|
||||
0000f70: 2a3c 70b7 35a3 ddbf 0000 0000 0000 0000 *<p.5...........
|
||||
0000f80: 74b6 c8b7 b940 7d3e 0000 0000 0000 0000 t....@}>........
|
||||
0000f90: 0000 0000 0000 0000 5885 1587 8115 863e ........X......>
|
||||
0000fa0: 0000 0000 0000 0000 5731 2901 cb37 8c3f ........W1)..7.?
|
||||
0000fb0: 0000 0000 0000 0000 78b2 2004 a4f6 93bf ........x. .....
|
||||
0000fc0: 0000 0000 0000 0000 0c44 e87d 42c8 38bf .........D.}B.8.
|
||||
0000fd0: 0000 0000 0000 0000 602d 038e a134 d2bd ........`-...4..
|
||||
0000fe0: 0000 0000 0000 0000 5caf 16ba 529a de3d ........\...R..=
|
||||
0000ff0: 0000 0000 0000 0000 309b d8db 54ed 7abe ........0...T.z.
|
||||
0001000: 0000 0000 0000 0000 5834 d03b cd6f c83d ........X4.;.o.=
|
||||
0001010: 0000 0000 0000 0000 40d4 d431 2db2 2f3e ........@..1-./>
|
||||
0001020: 0000 0000 0000 0000 0a .........
|
BIN
python/converters/vasp/test/plocar_io/PLOCAR.prec8
Normal file
BIN
python/converters/vasp/test/plocar_io/PLOCAR.prec8
Normal file
Binary file not shown.
272
python/converters/vasp/test/plocar_io/PLOCAR.prec8.out
Normal file
272
python/converters/vasp/test/plocar_io/PLOCAR.prec8.out
Normal file
@ -0,0 +1,272 @@
|
||||
nlm = 9
|
||||
1 1 1 1 2.00000
|
||||
1 0.0000000 0.0000000
|
||||
2 0.4050880 0.0000000
|
||||
3 0.4029369 0.0000000
|
||||
4 0.4057568 0.0000000
|
||||
5 -0.0000006 0.0000000
|
||||
6 -0.0000004 0.0000000
|
||||
7 0.0000001 0.0000000
|
||||
8 -0.0000004 0.0000000
|
||||
9 0.0000002 0.0000000
|
||||
1 1 1 2 2.00000
|
||||
1 -0.0000000 0.0000000
|
||||
2 0.1930381 0.0000000
|
||||
3 -0.6538923 0.0000000
|
||||
4 0.4568927 0.0000000
|
||||
5 -0.0000004 0.0000000
|
||||
6 -0.0000007 0.0000000
|
||||
7 -0.0000007 0.0000000
|
||||
8 0.0000001 0.0000000
|
||||
9 0.0000003 0.0000000
|
||||
1 1 1 3 2.00000
|
||||
1 0.0000000 0.0000000
|
||||
2 -0.7428721 0.0000000
|
||||
3 0.1099217 0.0000000
|
||||
4 0.6337009 0.0000000
|
||||
5 0.0000011 0.0000000
|
||||
6 0.0000017 0.0000000
|
||||
7 0.0000004 0.0000000
|
||||
8 -0.0000001 0.0000000
|
||||
9 -0.0000001 0.0000000
|
||||
1 1 1 4 2.00000
|
||||
1 -0.3182364 0.0000000
|
||||
2 0.0000000 0.0000000
|
||||
3 -0.0000000 0.0000000
|
||||
4 -0.0000000 0.0000000
|
||||
5 0.0000001 0.0000000
|
||||
6 0.0000001 0.0000000
|
||||
7 0.0000000 0.0000000
|
||||
8 0.0000001 0.0000000
|
||||
9 0.0000000 0.0000000
|
||||
1 1 1 5 2.00000
|
||||
1 -0.0000008 0.0000000
|
||||
2 -0.0000013 0.0000000
|
||||
3 0.0000010 0.0000000
|
||||
4 0.0000008 0.0000000
|
||||
5 -0.3314341 0.0000000
|
||||
6 -0.3414627 0.0000000
|
||||
7 -0.0000000 0.0000000
|
||||
8 -0.3413397 0.0000000
|
||||
9 -0.0000000 0.0000000
|
||||
1 1 1 6 2.00000
|
||||
1 -0.0000006 0.0000000
|
||||
2 -0.0000005 0.0000000
|
||||
3 -0.0000009 0.0000000
|
||||
4 -0.0000006 0.0000000
|
||||
5 0.5355566 0.0000000
|
||||
6 -0.2614713 0.0000000
|
||||
7 -0.0000001 0.0000000
|
||||
8 -0.2587571 0.0000000
|
||||
9 0.0000000 0.0000000
|
||||
1 1 1 7 2.00000
|
||||
1 0.0000003 0.0000000
|
||||
2 -0.0000010 0.0000000
|
||||
3 0.0000006 0.0000000
|
||||
4 0.0000010 0.0000000
|
||||
5 -0.0019230 0.0000000
|
||||
6 -0.5896138 0.0000000
|
||||
7 0.0000000 0.0000000
|
||||
8 0.5917712 0.0000000
|
||||
9 0.0000001 0.0000000
|
||||
1 1 1 8 0.00000
|
||||
1 -0.0000006 0.0000000
|
||||
2 -0.0000002 0.0000000
|
||||
3 0.0000002 0.0000000
|
||||
4 -0.0000002 0.0000000
|
||||
5 -0.0000000 0.0000000
|
||||
6 0.0000001 0.0000000
|
||||
7 -0.0384668 0.0000000
|
||||
8 -0.0000001 0.0000000
|
||||
9 0.8256005 0.0000000
|
||||
1 1 1 9 0.00000
|
||||
1 0.0000013 0.0000000
|
||||
2 -0.0000007 0.0000000
|
||||
3 0.0000009 0.0000000
|
||||
4 0.0000001 0.0000000
|
||||
5 -0.0000001 0.0000000
|
||||
6 0.0000000 0.0000000
|
||||
7 -0.6450752 0.0000000
|
||||
8 0.0000000 0.0000000
|
||||
9 -0.0484466 0.0000000
|
||||
1 1 2 1 2.00000
|
||||
1 0.0000000 0.0000000
|
||||
2 0.6894316 0.0000000
|
||||
3 0.6894316 0.0000000
|
||||
4 0.0000003 0.0000000
|
||||
5 -0.0000009 0.0000000
|
||||
6 -0.0000008 0.0000000
|
||||
7 -0.0000003 0.0000000
|
||||
8 0.0000010 0.0000000
|
||||
9 0.0000001 0.0000000
|
||||
1 1 2 2 2.00000
|
||||
1 0.0000000 0.0000000
|
||||
2 0.0000002 0.0000000
|
||||
3 0.0000002 0.0000000
|
||||
4 -0.9184595 0.0000000
|
||||
5 0.0000008 0.0000000
|
||||
6 0.0000001 0.0000000
|
||||
7 -0.0000000 0.0000000
|
||||
8 -0.0000008 0.0000000
|
||||
9 0.0000000 0.0000000
|
||||
1 1 2 3 2.00000
|
||||
1 -0.0000000 0.0000000
|
||||
2 0.5870812 0.0000000
|
||||
3 -0.5870812 0.0000000
|
||||
4 -0.0000000 0.0000000
|
||||
5 0.0000000 0.0000000
|
||||
6 0.0000006 0.0000000
|
||||
7 0.0000002 0.0000000
|
||||
8 -0.0000000 0.0000000
|
||||
9 -0.0000005 0.0000000
|
||||
1 1 2 4 2.00000
|
||||
1 0.0652648 0.0000000
|
||||
2 -0.0000003 0.0000000
|
||||
3 0.0000005 0.0000000
|
||||
4 0.0000015 0.0000000
|
||||
5 0.0000000 0.0000000
|
||||
6 -0.2135086 0.0000000
|
||||
7 -0.0808953 0.0000000
|
||||
8 0.0000000 0.0000000
|
||||
9 0.1401148 0.0000000
|
||||
1 1 2 5 2.00000
|
||||
1 0.0000012 0.0000000
|
||||
2 -0.0000015 0.0000000
|
||||
3 -0.0000016 0.0000000
|
||||
4 0.0000004 0.0000000
|
||||
5 -0.5060075 0.0000000
|
||||
6 0.0000005 0.0000000
|
||||
7 0.0000002 0.0000000
|
||||
8 0.5060075 0.0000000
|
||||
9 -0.0000002 0.0000000
|
||||
1 1 2 6 0.66667
|
||||
1 -0.0000000 0.0000000
|
||||
2 0.0431911 0.0000000
|
||||
3 0.0431911 0.0000000
|
||||
4 -0.0000000 0.0000000
|
||||
5 0.0000000 0.0000000
|
||||
6 -0.0000000 0.0000000
|
||||
7 -0.0000000 0.0000000
|
||||
8 -0.0000000 0.0000000
|
||||
9 0.0000000 0.0000000
|
||||
1 1 2 7 0.00000
|
||||
1 -0.0242085 0.0000000
|
||||
2 0.0000003 0.0000000
|
||||
3 0.0000001 0.0000000
|
||||
4 -0.0000002 0.0000000
|
||||
5 -0.0000000 0.0000000
|
||||
6 0.1925365 0.0000000
|
||||
7 -0.1427571 0.0000000
|
||||
8 -0.0000000 0.0000000
|
||||
9 0.2472626 0.0000000
|
||||
1 1 2 8 0.00000
|
||||
1 0.0000019 0.0000000
|
||||
2 -0.0000001 0.0000000
|
||||
3 0.0000000 0.0000000
|
||||
4 0.0000000 0.0000000
|
||||
5 0.0000000 0.0000000
|
||||
6 0.0000033 0.0000000
|
||||
7 -0.0619411 0.0000000
|
||||
8 0.0000000 0.0000000
|
||||
9 -0.0357636 0.0000000
|
||||
1 1 2 9 0.00000
|
||||
1 0.0000000 0.0000000
|
||||
2 0.0000001 0.0000000
|
||||
3 0.0000001 0.0000000
|
||||
4 0.0000000 0.0000000
|
||||
5 -0.2827905 0.0000000
|
||||
6 0.0000001 0.0000000
|
||||
7 0.0000000 0.0000000
|
||||
8 -0.2827905 0.0000000
|
||||
9 -0.0000001 0.0000000
|
||||
1 1 3 1 2.00000
|
||||
1 -0.0000000 0.0000000
|
||||
2 -0.0607441 0.0000000
|
||||
3 -0.0633386 0.0000000
|
||||
4 -0.0619857 0.0000000
|
||||
5 -0.0000001 0.0000000
|
||||
6 0.0000001 0.0000000
|
||||
7 0.0000006 0.0000000
|
||||
8 0.0000000 0.0000000
|
||||
9 -0.0000004 0.0000000
|
||||
1 1 3 2 2.00000
|
||||
1 -0.0000000 0.0000000
|
||||
2 -0.2519223 0.0000000
|
||||
3 0.3270304 0.0000000
|
||||
4 -0.0742897 0.0000000
|
||||
5 0.0000000 0.0000000
|
||||
6 -0.0000000 0.0000000
|
||||
7 -0.0000011 0.0000000
|
||||
8 0.0000000 0.0000000
|
||||
9 0.0000008 0.0000000
|
||||
1 1 3 3 2.00000
|
||||
1 0.0000000 0.0000000
|
||||
2 0.1061079 0.0000000
|
||||
3 0.1572919 0.0000000
|
||||
4 -0.2623809 0.0000000
|
||||
5 -0.0000000 0.0000000
|
||||
6 0.0000000 0.0000000
|
||||
7 0.0000003 0.0000000
|
||||
8 0.0000000 0.0000000
|
||||
9 -0.0000001 0.0000000
|
||||
1 1 3 4 2.00000
|
||||
1 -0.0000000 0.0000000
|
||||
2 0.0000000 0.0000000
|
||||
3 -0.0000000 0.0000000
|
||||
4 -0.0000001 0.0000000
|
||||
5 -0.0000000 0.0000000
|
||||
6 0.0000000 0.0000000
|
||||
7 0.0000645 0.0000000
|
||||
8 -0.0000000 0.0000000
|
||||
9 -0.5631694 0.0000000
|
||||
1 1 3 5 2.00000
|
||||
1 0.0000000 0.0000000
|
||||
2 -0.0000005 0.0000000
|
||||
3 0.0000006 0.0000000
|
||||
4 0.0000001 0.0000000
|
||||
5 -0.0000000 0.0000000
|
||||
6 0.0000000 0.0000000
|
||||
7 0.7211366 0.0000000
|
||||
8 0.0000000 0.0000000
|
||||
9 0.0000478 0.0000000
|
||||
1 1 3 6 0.00000
|
||||
1 -0.0000010 0.0000000
|
||||
2 0.0000001 0.0000000
|
||||
3 -0.0000001 0.0000000
|
||||
4 0.0000003 0.0000000
|
||||
5 -0.4425794 0.0000000
|
||||
6 -0.5088829 0.0000000
|
||||
7 -0.0000000 0.0000000
|
||||
8 -0.5129848 0.0000000
|
||||
9 0.0000000 0.0000000
|
||||
1 1 3 7 0.00000
|
||||
1 0.0000000 0.0000000
|
||||
2 0.0000001 0.0000000
|
||||
3 -0.0000001 0.0000000
|
||||
4 -0.0000000 0.0000000
|
||||
5 -0.6791375 0.0000000
|
||||
6 0.2412815 0.0000000
|
||||
7 -0.0000002 0.0000000
|
||||
8 0.3450642 0.0000000
|
||||
9 -0.0000001 0.0000000
|
||||
1 1 3 8 0.00000
|
||||
1 -0.0000000 0.0000000
|
||||
2 0.0000001 0.0000000
|
||||
3 -0.0000000 0.0000000
|
||||
4 0.0000002 0.0000000
|
||||
5 -0.0362770 0.0000000
|
||||
6 0.4965687 0.0000000
|
||||
7 -0.0000001 0.0000000
|
||||
8 -0.4630865 0.0000000
|
||||
9 0.0000001 0.0000000
|
||||
1 1 3 9 0.00000
|
||||
1 0.0000002 0.0000000
|
||||
2 0.0137783 0.0000000
|
||||
3 -0.0194955 0.0000000
|
||||
4 -0.0003781 0.0000000
|
||||
5 -0.0000000 0.0000000
|
||||
6 0.0000000 0.0000000
|
||||
7 -0.0000001 0.0000000
|
||||
8 0.0000000 0.0000000
|
||||
9 0.0000000 0.0000000
|
||||
|
BIN
python/converters/vasp/test/plocar_io/PLOCAR.trunc
Normal file
BIN
python/converters/vasp/test/plocar_io/PLOCAR.trunc
Normal file
Binary file not shown.
56
python/converters/vasp/test/plocar_io/mytest.py
Normal file
56
python/converters/vasp/test/plocar_io/mytest.py
Normal file
@ -0,0 +1,56 @@
|
||||
r"""
|
||||
Module defining a custom TestCase with extra functionality.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import numpy as np
|
||||
import difflib
|
||||
|
||||
class MyTestCase(unittest.TestCase):
|
||||
"""
|
||||
Custom TestCase class supporting additional equality checks:
|
||||
- numpy array equality
|
||||
- file equality
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
Initializes a custom equality function for comparing numpy arrays.
|
||||
"""
|
||||
super(MyTestCase, self).__init__(*args, **kwargs)
|
||||
self.addTypeEqualityFunc(np.ndarray, self.is_arrays_equal)
|
||||
|
||||
def is_arrays_equal(self, arr1, arr2, msg=None):
|
||||
"""
|
||||
Raises self.failureException is arrays arr1 and arr2
|
||||
are not equal.
|
||||
"""
|
||||
if not np.allclose(arr1, arr2):
|
||||
raise self.failureException(msg)
|
||||
|
||||
def assertFileEqual(self, file1, file2):
|
||||
"""
|
||||
Compares two files using difflib.
|
||||
Empty lines are ignored.
|
||||
Files are assumed to be relatively small, otherwise
|
||||
the data is truncated.
|
||||
"""
|
||||
MAX_SIZE = 100000
|
||||
with open(file1, 'r') as f1:
|
||||
str1 = f1.read(MAX_SIZE)
|
||||
with open(file2, 'r') as f2:
|
||||
str2 = f2.read(MAX_SIZE)
|
||||
#
|
||||
# Make a diff
|
||||
#
|
||||
# Remove empty lines
|
||||
lstr1 = filter(lambda s: s.strip() != '', str1.splitlines(True))
|
||||
lstr2 = filter(lambda s: s.strip() != '', str2.splitlines(True))
|
||||
# diff
|
||||
delta = difflib.unified_diff(lstr1, lstr2)
|
||||
# combine delta's to a string
|
||||
diff = ''.join(delta)
|
||||
# if 'diff' is non-empty, files are different
|
||||
if diff:
|
||||
return self.fail("Files '%s' and '%s' differ"%(file1, file2))
|
||||
|
||||
|
1
python/converters/vasp/test/plocar_io/runtest.sh
Executable file
1
python/converters/vasp/test/plocar_io/runtest.sh
Executable file
@ -0,0 +1 @@
|
||||
PYTHONPATH=../../python:../../c:$PYTHONPATH python $1
|
93
python/converters/vasp/test/plocar_io/test_fileio.py
Normal file
93
python/converters/vasp/test/plocar_io/test_fileio.py
Normal file
@ -0,0 +1,93 @@
|
||||
r"""
|
||||
Tests of 'read_plocar()' from module 'plocar_io.c_plocar_io'
|
||||
"""
|
||||
import mytest
|
||||
import numpy as np
|
||||
from plocar_io.c_plocar_io import read_plocar
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# TestFileIO
|
||||
#
|
||||
################################################################################
|
||||
class TestFileIO(mytest.MyTestCase):
|
||||
"""
|
||||
Function:
|
||||
|
||||
def read_plocar(filename)
|
||||
|
||||
Scenarios:
|
||||
|
||||
- **if** file PLOCAR does not exist **raise** IOError
|
||||
- **if** PLOCAR is truncated **raise** IOError
|
||||
- **if** the precision flag is not 4 or 8 **raise** ValueError
|
||||
- **if** PLOCAR with prec=8 is read **compare** the output
|
||||
- **if** PLOCAR with prec=4 is read **compare** the output
|
||||
"""
|
||||
# Scenario 1
|
||||
def test_no_plocar(self):
|
||||
err_mess = "Error opening xPLOCAR"
|
||||
with self.assertRaisesRegexp(IOError, err_mess):
|
||||
read_plocar('xPLOCAR')
|
||||
|
||||
# Scenario 2
|
||||
def test_end_of_file(self):
|
||||
err_mess = "End-of-file reading"
|
||||
with self.assertRaisesRegexp(IOError, err_mess):
|
||||
read_plocar('PLOCAR.trunc')
|
||||
|
||||
# Scenario 3
|
||||
def test_wrong_prec(self):
|
||||
err_mess = "only 'prec = 4, 8' are supported"
|
||||
with self.assertRaisesRegexp(ValueError, err_mess):
|
||||
read_plocar('PLOCAR.noprec')
|
||||
|
||||
# Scenario 4
|
||||
def test_plocar_prec8(self):
|
||||
pars, plo, ferw = read_plocar('PLOCAR.prec8')
|
||||
nion, ns, nk, nb, nlm = plo.shape
|
||||
|
||||
test_file = 'PLOCAR.prec8.out.test'
|
||||
with open(test_file, 'wt') as f:
|
||||
f.write(" nlm =%5i\n"%(nlm))
|
||||
ion = 1
|
||||
isp = 1
|
||||
for ik in xrange(nk):
|
||||
for ib in xrange(nb):
|
||||
f.write("%5i%5i%5i%5i%10.5f\n"%(ion, isp, ik+1, ib+1, ferw[0, 0, ik, ib]))
|
||||
for ilm in xrange(nlm):
|
||||
p = plo[0, 0, ik, ib, ilm]
|
||||
f.write("%5i%15.7f%15.7f\n"%(ilm+1, p.real, p.imag))
|
||||
|
||||
expected_file = 'PLOCAR.prec8.out'
|
||||
self.assertFileEqual(test_file, expected_file)
|
||||
|
||||
# Scenario 5
|
||||
def test_plocar_example(self):
|
||||
pars, plo, ferw = read_plocar('PLOCAR.example')
|
||||
nion, ns, nk, nb, nlm = plo.shape
|
||||
|
||||
self.assertEqual(pars['nion'], nion)
|
||||
self.assertEqual(pars['ns'], ns)
|
||||
self.assertEqual(pars['nk'], nk)
|
||||
self.assertEqual(pars['nb'], nb)
|
||||
|
||||
test_file = 'PLOCAR.example.out.test'
|
||||
with open(test_file, 'wt') as f:
|
||||
f.write("pars: %s\n"%(pars))
|
||||
for ion in xrange(nion):
|
||||
for isp in xrange(ns):
|
||||
for ik in xrange(nk):
|
||||
for ib in xrange(nb):
|
||||
f.write("%5i%5i%5i%5i %s\n"%(ion+1, isp+1, ik+1, ib+1,
|
||||
ferw[ion, isp, ik, ib]))
|
||||
for ilm in xrange(nlm):
|
||||
p = plo[ion, isp, ik, ib, ilm]
|
||||
f.write("%5i %s\n"%(ilm+1, p))
|
||||
|
||||
expected_file = 'PLOCAR.example.out'
|
||||
self.assertFileEqual(test_file, expected_file)
|
||||
|
||||
|
||||
|
||||
|
10
python/converters/vasp/test/plocar_io/test_plocar_io.py
Normal file
10
python/converters/vasp/test/plocar_io/test_plocar_io.py
Normal file
@ -0,0 +1,10 @@
|
||||
r"""
|
||||
Test suite for module `plocar_io`.
|
||||
"""
|
||||
import unittest
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestLoader().discover('./')
|
||||
unittest.TextTestRunner(verbosity=2, buffer=True).run(suite)
|
||||
# unittest.TextTestRunner(verbosity=2, buffer=False).run(suite)
|
||||
|
Loading…
Reference in New Issue
Block a user