Repository navigation
fix(core): check projection axes against bands and structure, and give every parser its orbital names - #298
Conversation
ceac04e to
959fe37
Compare
|
VERDICT: FAIL Reviewed SHA: 38b2524 (base origin/dev bf65596, which is also the merge base, so no trunk merge was needed). Lane: audit + regression. The PR head and dev did not move while I reviewed. What I ran (detached worktrees,
|
|
VERDICT: PASS+NOTES Reviewed SHA: 38b2524 (base origin/dev bf65596; the merge-base equals origin/dev, so no merge with trunk was needed). Lane: Live + red/green + gates. Gates at head (the commands from
Live: the QE spinor conversion (acceptance item 1)
Live: the layout check against every parser and every fixture (acceptance items 2 and 3)
Red/green (acceptance item 5)
Acceptance
Notes (none blocking)
|
38b2524 to
d5e8b82
Compare
|
VERDICT: FAIL Reviewed SHA: b1a8d63 (round 2), on origin/dev 3ae5842, which is also the merge base. Lane: audit + regression. Neither the head nor dev moved while I reviewed. What I ranAll runs used detached worktrees,
Acceptance (#293)Items 1 to 4 are still done. I re-ran the regression from round 1: QE non-collinear The round-1 blocker is fixedAt head, atom-filtered PROCARs load with a warning, and
Results of the user entry points:
A genuine swap still raises with FindingsBlocking: with no structure, a DOS selection without
Regression comparison of selections, origin/dev against head, 50 fixtures.
Notes:
|
|
VERDICT: PASS+NOTES Reviewed SHA: b1a8d63. It is rebased onto origin/dev 3ae5842, which is also its merge-base. Lane: Live + red/green + gates (round 2). Gates at head (the commands from
Live: filtered PROCARs through the one-call functions, head against origin/dev
Shell selection by letters and indices, per code
Spinor reference at the new head
Layout-check sweep and the swapped-axis raise
Red/green and mutants
Acceptance (frozen set, unchanged)
Notes (none blocking)
|
b1a8d63 to
ed1c03d
Compare
|
VERDICT: PASS+NOTES Reviewed SHA: 625821d. I ran everything on that SHA merged with origin/dev f243254 (merge-tree clean, merged tree 3ad04be6). The comparison baseline is origin/dev f243254. Lane: Live + red/green + gates (round 3). Gates on the merged tree (the
Round-2 blocker: a DOS without a structure. Fixed. I checked it against values I computed with numpy from arrays I built.
Selections with no atoms on real fixtures: explicit rows equal the old "all rows".
Filtered PROCARs
Empty selections
Red/green. I ran head's 10 changed test files against origin/dev's library: 47 failed, 95 passed. Each round-3 test fails for the reason it states:
Mutants. I ran each against the 11 changed test files, data tests included, and restored the source after each;
Spinor reference at the head
Notes (none blocking)
|
|
VERDICT: FAIL Reviewed SHA: 625821d (round 3). The PR head did not move during the review. Trunk moved during the review. Blocking: head merged with current dev (5d6ae01) fails CIEvery failure below comes from two lines this PR adds. Each passes on 5d6ae01 alone.
The two quick-suite failures are #294's enforcement tests:
The data failure is User-facing repro. Copy Fix.
Round-3 audit (on head + f243254, the trunk named at spawn)Resolver consumers. I grepped every
Synthetic structure-less DOS (2 rows), at origin/dev, the round-2 head (b1a8d63) and the round-3 head:
On a VASP DOS that has a structure, origin/dev returns an empty Regression dump of every parser on 55 fixture dirs. The dirs are all of
One-call functions with default selections, 183 matplotlib runs and 21 PyVista runs, origin/dev against head:
ibz2fbz refusal. It fired on no unfiltered irreducible mesh (QE, Abinit, VASP, Data suite, Gates on head + f243254. basedpyright: 0 errors. Both #293 acceptance. All 4 items are done.
PR body round-3 section. Its line references match the code ( Notes (not blocking)
|
…cture are rejected Refs #293
…ucture check_projected_layout compared only the number of axes, so swapped spin and atom axes passed. It now compares the leading axes with the bands or total DOS, the atom axis with the structure, and requires 1, 2 or 4 spin channels. Non-collinear projections may go with one band channel, as the QE parser stores them, or four, as VASP and Abinit do. Refs #293
…orbital projwfc.x projects a spinor run onto |l j m_j> (spin-orbit) or |l m s_z> states. The parser summed the j amplitudes into 32 slots on one spin channel and could not read s_z states. It now writes each shell in the real (l, m) harmonics and spin up/down with QE's own spinor, sph_ind and rot_ylm coefficients, and stores total, Sx, Sy and Sz per orbital. Both QE band structures and DOS now pass projwfc.x's orbital names. Refs #293, #219, #220
VASP and Abinit read the names from the PROCAR header instead of cutting a fixed list, so a PROCAR that pyprocar.filter rewrote keeps its o0 column name. The Abinit, Elk and Lobster DOS now name their orbital columns too, so check_projected_layout compares them. Refs #293
…nels Abinit's DOS_AT files hold no magnetization components. With nspden 1 the spin-resolved DOS is zero by time reversal, so the parser adds three zero channels. With nspden 4 it keeps the total and warns, since the files cannot give the spin components. Refs #293
… to every DOS - QE spin-orbit DOS names reuse OrbitalIndexer.soc_label, the format the label builder already renders. - Abinit DOS names are a constant: the kept lm columns are a fixed slice. - Procar.n_orbitals counts the header names instead of rescanning. - The spinor transform uses a matrix product and adds in place. - The QE, Abinit and Elk DOS pass their structure, so the atom axis is checked against it. Refs #293
…ader does An atom-filtered PROCAR holds one row per group of atoms, so it loads, plots each group, labels it by its row and refuses species selections. An orbital-filtered PROCAR labels its columns o0, o1 as its header does, and a single orbital selected by name raises whichever spelling the header uses. Refs #293
Elk's task 21 and pyprocar.filter(orbital_names=['s','p','d']) write one column per shell, named by its letter. orbitals=['d'] picked columns 4-8 there (IndexError, or a wrong sum when the columns existed). It now picks the column named d, and overlay_orbitals draws one curve per such column. Refs #293
…ell, filtered IBZ PROCARs refuse to unfold A DensityOfStates without a structure (every Lobster DOS) gave zeros for compute_projected_sum and compute_magnetization without atoms, and dosplot parametric coloured a Lobster DOS 0. Columns py and pz must not form a p shell. fermi2D on an atom-filtered PROCAR of irreducible k-points failed with an IndexError once ibz2fbz started permuting atoms (#299). Refs #293
With no structure the resolver returned atoms=(), which the band and Fermi surface callers read as every row but DensityOfStates passed on as no rows, so a Lobster DOS (no structure) summed to zero. The resolver now takes the source's row count and always returns explicit row indices, and every caller passes them as given. An empty atom selection raises. Refs #293
…-points ibz2fbz (#299) permutes atoms under each symmetry operation, so a PROCAR whose rows are groups of atoms failed with an IndexError in fermi2D and every other mesh. The file does not record which atoms a row holds, so no permutation of its rows is known to be right. It now raises an error that says to filter a full k-grid calculation or select atoms in the plot. Refs #293
…euse the test helpers The atom-group guard ran inside _turn_projections, after ibz2fbz had already replaced the properties, and refused every symmetry operation. It now runs first and refuses only operations that move an atom. The fermi2D test builds its filtered calculation with _filtered_calc, and the DOS tests import VASP_ORBITALS instead of copying it (simplify review). Refs #293
The resolver returned spins=(), which band callers read as every spin and DensityOfStates as none. Refs #293
…warn_user #294 removed user_logger from the Abinit parser and made warn_user the only channel for warnings a user must see, so the merge left a NameError at io/abinit/parser.py and a raw warnings.warn in io/vasp/parser.py. The Abinit test now asserts the warning names its own line.
625821d to
ea94998
Compare
|
VERDICT: PASS+NOTES Reviewed SHA: ea94998 (head of #298, based on origin/dev 5d6ae01, so head and head merged with dev are the same tree). The patch is 625821d's patch plus this one commit. I compared
ea94998 itself changes three things:
Every gate the audit found red is now green (
Live, through the public API. I used private copies inside my worktree; nothing was written under
Notes (non-blocking):
|
build_overlay_orbitals_weights and build_overlay_weights called .get on pyprocar.utils.info.orbital_names, a list, so both raised AttributeError. They now take the shells from orbital_shells(self.orbital_names), the definition #298 added, so a PROCAR with only s and p orbitals gives s and p, and a shell letter the orbitals do not hold raises a ValueError.
Since #298 the QE parser names its orbitals as projwfc.x prints them. ibz2fbz did not know the three f labels fzx2-zy2, fx3-3xy2 and f3yx2-y3, so it dropped a QE mesh's phases and left f unrotated. Against QE 7.5 nosym runs, V eg weights were off by 0.30 and La f by 1.0. ORBITAL_ALIASES now maps the three labels. QE's real harmonics carry the sign (-1)^|m| (upflib/ylmr2.f90), and the core's carry none. The parser now writes the phases over the core's harmonics. Without that the kept phases unfold with wrong signs on px, py, dxz, dyz, fxz2, fyz2, fx3-3xy2 and f3yx2-y3, and phase products are off by up to 1.4. Refs #293
build_overlay_orbitals_weights and build_overlay_weights called .get on pyprocar.utils.info.orbital_names, a list, so both raised AttributeError. They now take the shells from orbital_shells(self.orbital_names), the definition #298 added, so a PROCAR with only s and p orbitals gives s and p, and a shell letter the orbitals do not hold raises a ValueError.
Since #298 the QE parser names its orbitals as projwfc.x prints them. ibz2fbz did not know the three f labels fzx2-zy2, fx3-3xy2 and f3yx2-y3, so it dropped a QE mesh's phases and left f unrotated. Against QE 7.5 nosym runs, V eg weights were off by 0.30 and La f by 1.0. ORBITAL_ALIASES now maps the three labels. QE's real harmonics carry the sign (-1)^|m| (upflib/ylmr2.f90), and the core's carry none. The parser now writes the phases over the core's harmonics. Without that the kept phases unfold with wrong signs on px, py, dxz, dyz, fxz2, fyz2, fx3-3xy2 and f3yx2-y3, and phase products are off by up to 1.4. Refs #293
…S2D grid, overlay weights, Elk lmirep) (#304) * test(dos): vertical spin-polarized DOS labels and flips each channel * fix(dos): split spin channels before orienting a vertical DOS plot DOSPlotter.plot swapped energies and values before it split the spin channels, so in vertical orientation (bandsdosplot) every channel got the first channel's label and the down channel was not mirrored. * test(autobandsplot): write report.txt only to the path the caller names * fix(autobandsplot): write the report only to the path given as report= autobandsplot wrote report.txt into the current working directory on every call. The report now goes to the path the caller passes as report=, and no file is written by default. Energies and band indexes print as plain numbers again, so the text matches the reference report shipped with the bands/auto fixture. * test(procarparser): read fused fixed-width k-point coordinates * fix(procarparser): read fused fixed-width k-point coordinates The legacy ProcarParser split k-point headers on whitespace, so a header such as 0.50000000-0.25000000 0.00000000 gave two values and readFile raised. It now uses the per-coordinate regex that #280 put in io/vasp/procar.py. * test(cfg): the scatter plot-mode member is spelled SCATTER * fix(cfg): rename the SACATTER plot-mode member to SCATTER UnfoldPlotMode and both BandStructureMode enums spelled the scatter member SACATTER. Users select the mode by its value "scatter", which does not change, and no public namespace or doc names the member, so no alias is kept. * test(docs): cfg pages name existing files and show the config defaults * docs(cfg): render the config pages from the config classes The cfg index listed yml files that do not exist, and the dos, unfold and band-structure-2D pages were generated from yml files that no code reads and that had drifted from the config defaults (unfold showed color black instead of #eeeeee). Those pages now use automodule, like the band-structure and Fermi-surface-3D pages. The yml files and their generator are removed, and the config docstrings state the real defaults. * test(cli): run the filter and cat subcommands of scripts/procar.py * fix(cli): pass the filter subcommand's own argument names procar.py filter read args.infile, args.outfile and args.human_atoms, which its parser never defines (it defines inFile, outFile and --human), so every filter call raised AttributeError. * test(examples): saved band notebook outputs name only current plot options * docs(examples): clear stale saved outputs in the band notebooks The unfolding notebook kept plots drawn before #282 fixed pyprocar.unfold, and the Getting Started and Comparing Bands notebooks kept option dumps that list the removed weighted_color and weighted_width. Those outputs are cleared rather than re-run, so no new images enter the repo. * test(bs2d): a hexagonal k-patch is fully covered and each value stays on its own point * fix(bs2d): lay the 2D band grid over the k-patch and keep values on their points With as_cartesian=False the k-mesh slice is a parallelogram in Cartesian space, and the uv grid spanned its bounding box. For graphene half of the grid fell outside the data, so those points were NaN and the surface edge became a sawtooth. The grid is now regular in fractional coordinates and mapped to Cartesian. The band surfaces went through cast_to_unstructured_grid().extract_surface(), which renumbers points, while every property stayed in grid order, so colours were drawn on other points. The surface is now built from quads in grid order, which also fixes the dimensions of a non-square grid. * test(ebs): overlay weights sum the shells the orbital names hold * fix(ebs): build overlay weights from the shells the orbital names hold build_overlay_orbitals_weights and build_overlay_weights called .get on pyprocar.utils.info.orbital_names, a list, so both raised AttributeError. They now take the shells from orbital_shells(self.orbital_names), the definition #298 added, so a PROCAR with only s and p orbitals gives s and p, and a shell letter the orbitals do not hold raises a ValueError. * docs(examples): drop the overlay-builder bug notes the fix resolved * test(elk): name task-22 characters by the basis Elk wrote them in * fix(elk): name task-22 characters by the irreducible-representation basis Elk 10.7.8 and later write task 22's (l,m) band characters in each site's irreducible-representation basis unless lmirep is .false., so the Y{l}{m} names were wrong for those runs. The parser reads the version from INFO.OUT and lmirep from elk.in, and names those columns Y{l}_ir{i}, the i-th basis function of l in ELMIREP.OUT order; orbital_shells still finds each shell. Without INFO.OUT, ELMIREP.OUT from a task-22-only run marks the basis, and a run that also lists task 10 warns. * style(bs2d): split the fractional-grid mapping into ruff-formatted lines * docs(verify-pyprocar): record the #285 fixes in the feature map * refactor(orbitals): resolve shell names in one place for plots and overlay weights present_shells and orbital_indices move from scripts/_selection.py to core/atomic_orbital_index.py beside orbital_shells. The overlay weight builders call them, so they accept the same shell names as bandsplot(orbitals=[...]), including a single column named by its letter. The fixed orbital table in utils/info.py, whose last user was the broken overlay code, is removed. * refactor(bs2d): slice the plane once for the fractional grid * refactor(elk): share the elk.in logical parser and read the version line only * fix(types): type autobandsplot's fermi as a float and tidy the new tests for basedpyright * chore(basedpyright): drop baseline entries the #285 rewrites removed * style: wrap the #285 lines that ruff flags as too long or unformatted * test(bs2d): keep VTK objects out of failing test frames * test(bs2d): run the non-square grid build in its own process * test(elk): keep Ylm names for Elk 6.3 headers and for a task-10 ELMIREP.OUT without a version * fix(elk): read the Elk 6 version header and keep Ylm names when no version says otherwise * test(cfg): the old SACATTER member still resolves to SCATTER * fix(cfg): keep SACATTER as a deprecated alias of SCATTER * docs(changelog): note the autobandsplot report default and the SCATTER spelling * test(bs2d): cover the Cartesian grid, a near-square lattice, an off-origin skewed plane and the quads * test(bs2d): a Cartesian plane across the kz layers covers its patch * fix(bs2d): build the Cartesian-plane grid in the fractional patch and keep edge points inside the data * refactor: tighten the #285 round-2 grid and version code and format the new tests
Since #298 the QE parser names its orbitals as projwfc.x prints them. ibz2fbz did not know the three f labels fzx2-zy2, fx3-3xy2 and f3yx2-y3, so it dropped a QE mesh's phases and left f unrotated. Against QE 7.5 nosym runs, V eg weights were off by 0.30 and La f by 1.0. ORBITAL_ALIASES now maps the three labels. QE's real harmonics carry the sign (-1)^|m| (upflib/ylmr2.f90), and the core's carry none. The parser now writes the phases over the core's harmonics. Without that the kept phases unfold with wrong signs on px, py, dxz, dyz, fxz2, fyz2, fx3-3xy2 and f3yx2-y3, and phase products are off by up to 1.4. Refs #293
) * test(qe): QE phases unfold to the coefficients at each grid point After #299, a QE mesh dropped its phases and left the f shell unrotated, because the f labels projwfc.x prints are not the core's names; eg weights then lost their interference. QE's harmonics also carry the sign (-1)^m. Refs #293 * fix(qe): unfold QE phases and f orbitals with the core's harmonics Since #298 the QE parser names its orbitals as projwfc.x prints them. ibz2fbz did not know the three f labels fzx2-zy2, fx3-3xy2 and f3yx2-y3, so it dropped a QE mesh's phases and left f unrotated. Against QE 7.5 nosym runs, V eg weights were off by 0.30 and La f by 1.0. ORBITAL_ALIASES now maps the three labels. QE's real harmonics carry the sign (-1)^|m| (upflib/ylmr2.f90), and the core's carry none. The parser now writes the phases over the core's harmonics. Without that the kept phases unfold with wrong signs on px, py, dxz, dyz, fxz2, fyz2, fx3-3xy2 and f3yx2-y3, and phase products are off by up to 1.4. Refs #293 * fix(qe): keep the Bloch factor when the parser has no projwfc.x orbitals The harmonic sign flip needs projwfc.x's orbital list. When spd_phase is set without it, position_gauge_phase returned the phases with no exp(-2 pi i k.tau) factor, so test_ebs_phases_use_bloch_sums_over_atom_positions failed. Now the parser skips only the flip, and the Bloch factor always applies. The signs and the Bloch factor are combined first and applied in one multiply, so the parser no longer makes a second full-size copy of the phase array. Refs #293 * test(fermi): the Fermi-surface mesh pads projections but not phases Refs #293 * fix(ebs): drop projected_phase when padding a mesh QE meshes keep their phases since the sign fix, and the Fermi-surface path padded them: 9.2 GiB peak on the spin-polarized SrVO3 fermi fixture. Nothing reads phases on a padded mesh, and copies at k + G would be wrong because position-gauge phases are not periodic in k. Refs #293 * test(qe): unfolded QE bands are eigenvectors of their little group The data test checked only warnings and that phases were kept, so it passed with the sign flip reverted. Each nondegenerate band with V weight must be an eigenvector of the orbital rotation of every operation that fixes its k-point: max residual 3.6e-4 and 4.2e-4 over 52466 and 104884 checks by non-identity operations, against 1.0 without the flip. Refs #293 * docs(verify-pyprocar): state the band windows and image energies of the QE reference The 2.9e-4 LaVO3 figure holds over bands 1 to 31 of 34, and the 1e-9 eV energy agreement only at the IBZ k-points. Note the pad memory figure. Refs #293 * test: reuse the sphere mesh helpers and index each little group once Refs #293 * test(qe): narrow the optional mesh fields for basedpyright Refs #293 * docs(verify-pyprocar): state the band windows of the IBZ energy figures
Why
A user who loaded a QE non-collinear band structure got projections on one spin channel and 32 j-basis slots, so
spins=[3](Sz) raised anIndexErrorand an orbital selection such as V eg picked p states. The Abinit non-collinear DOS also had one channel.check_projected_layout(pyprocar/core/projection.py) counted axes only, so neither these layouts nor swapped spin and atom axes failed it. Five parsers passed no orbital names, and VASP cut a fixed list, so a filtered PROCAR whose header readso0was labelled['s'].What changed
check_projected_layoutcompares the projection's leading axes with the bands or total DOS, its atom axis with the structure, and requires 1, 2 or 4 spin channels. Its errors name the layout, for exampleexpects (2, 3, 1|4, *, *) from bands of shape (2, 3, 1). Non-collinear projections (total, Sx, Sy, Sz) may go with 1 band channel (QE) or 4 (VASP and Abinit repeat each eigenvalue).ebs.pychanges only the constructor call.pyprocar/io/qe/projwfc/spinor.pywrites each|l j m_j>(spin-orbit) or|l m s_z>shell in the real (l, m) harmonics and spin up and down. It uses QE 7.2's ownspinor,sph_indandrot_ylmcoefficients and gives total, Sx, Sy and Sz per orbital. The parser now readss_zstates and species labels with digits (the IndexError in QE Parser: re.findall for j= fails in non-collinear calc without SOC #219 and PyProcar QE parser fails for non-collinear calculations without SOC (s_z inst #220 input).nspden 1gets three zero spin channels. Time reversal makes its spin-resolved DOS zero. Every parser passes the names it projects: projwfc.x's labels for QE, the PROCAR header for VASP and Abinit bands, and the lm slots for the Abinit, Elk and Lobster DOS. The QE, Abinit and Elk DOS also pass their structure, so the atom check runs.Scope
CLAUDE.mdrule row.|l j m_j>weights, so Sx, Sy and Sz cannot be derived from them.nspden 4keeps its total projection and logs a warning. A local ABINIT 10.8.3 run withnspden 4wrote DOS_AT and DOS_TOTAL files without any magnetization columns.Tradeoffs
ibz2fbzand unfold tests, which Symmetry unfolding (ibz2fbz) follow-ups: ignored rotations, magnetic time reversal, phases and orbitals under rotation #283 owns. Allowing (1, 4) costs no checking power, because 4 projection channels can only mean non-collinear.projected_phaseis nowNone. A spinor has no single phase per orbital, and the unfolder indexes phases by projection channel.o0.pyprocar.filterwrites that name for a sum over orbitals the user chose, and the header is the only record of what the column holds.swould name an orbital the column is not.Blast Radius
Every
ElectronicBandStructureandDensityOfStatesconstruction runs the stronger check. All parsers on all fixtures underdata/codesanddata/examplespass it, and the full test suite passes. QE non-collinear users get a new orbital layout (16 real orbitals, 4 channels instead of 32 slots on 1).Verification
26 new tests in
tests/pyprocar/core/test_projected_layout.py,tests/pyprocar/io/qe/test_noncollinear_projections.py,tests/pyprocar/io/test_orbital_names.pyandtests/pyprocar/io/abinit/test_dos.py. 22 fail onorigin/devand pass at head; the other 4 guard the spin layouts that must stay accepted. Their expected values come from hand-derived QE spinor amplitudes, projwfc.x's own weights and Löwdin labels, Abinit's PROCAR header, Elk'sELMIREP.OUTand the integrated DOS columns. Full suite at head:pytest tests -n 8gives 2313 passed, 3 skipped. basedpyright and bothruff_new_violations.pygates pass.QE SrVO3 spin-orbit bands at Gamma: V t2g and eg weights are (0.984, 0.000) for band 41 and (0.000, 0.833) for band 47. These match
kpdos.out's j-state sums and the cubic crystal field. The V eg plot before and after:Independent QE 7.5 runs of bcc Fe with the moment tilted to theta 60, phi 30, with and without spin-orbit coupling. pw.x reports the site moment at theta 60.00, phi 30.00. pyprocar's spin of band 1 at Gamma is (0.750, 0.433, 0.500) of its total in both runs, the direction (sin 60 cos 30, sin 60 sin 30, cos 60). Over all bands and k-points, every Fe d spin above 0.1 lies within 6 degrees of the moment.
Round 2: PROCARs written by
pyprocar.filterThe round-1 audit found that a PROCAR filtered by atoms no longer loaded, that a filtered
o0column was still labelled(s), and asked whether selecting an orbital by name survives the header-based VASP names.pyprocar.filter(..., atoms=[[0],[1],[2,3,4]])writes one row per group of atoms, so the PROCAR had 3 rows next to a 5-atom POSCAR and the new atom check raised. The VASP parser (pyprocar/io/vasp/parser.py,ebs) now passesatom_groups, the PROCAR's ion count, when it differs from the structure, and warns.check_projected_layoutcompares the atom axis with that count, so a swapped atom and orbital axis still raises (test_band_structure_of_atom_groups_checks_the_atom_axis_against_the_group_count). Atom indexiselects thei-th group and is labelled by its index. A selection with no atoms sums every group, whereorigin/devraisedIndexError. Species selections (atoms=['O'],overlay_species,items) raise aValueErrorthat names the filtered PROCAR, because a group can hold several species. The structure stays on the band structure for the lattice and the symmetry operations. (Corrected in round 3:fermi2Don an atom-filtered PROCAR of irreducible k-points now raises instead of unfolding. See Round 3.)docs/source/user-guide/filter.rstsays all of this.OrbitalIndexerput a shell letter before it read the names (pyprocar/core/atomic_orbital_index.py,_build_label_tokens), so index 0 always reads. The neworbital_shellstakes shell l to be the 2l+1 orbitals whose names have angular momentum l. QE, Abinit, Elk (Y1-1) and both VASP spellings keeppandd. A filteredo0now readsBi-(o0)onexamples/bands/auto(Bi-(s)before). A QE spin-orbit j state no longer readss.orbitals=['p']andoverlay_orbitalsused the fixed table s=0, p=1-3, d=4-8 (pyprocar/scripts/_selection.py). They now take shells fromorbital_shellstoo. A shell is either its 2l+1 named orbitals or one column named by its letter, the sum that Elk's task 21 andpyprocar.filter(orbital_names=['s','p','d'])write. On standard VASP, QE, Abinit and Elk names the indices are unchanged. A shell name with no such columns raiseshold no whole p shell, whereorigin/devraisedIndexErroror summed the wrong columns.overlay_orbitalson the QE spin-orbit DOS (32 j states) now raises instead of drawing j slots 0, 1-3 and 4-8 as s, p and d.orbitalstakes indices and the shell namess,p,dandf. A single name such asx2-y2ordx2raisedKeyErroron every file before. It now raisesValueError: orbitals takes orbital indices or the shell names s, p, d, f, not 'dx2'...for both spellings on both header versions, so no selection depends on which spelling a VASP version writes.unfoldresolves species names through the selection resolver, asbandsplotnow does, so an atom-filtered PROCAR refuses them there too.ProjectionSelectionResolver.resolve): with no structure and no atom or species selection, it now selects every atom row instead of raisingAtom indexer is required. Grouped rows need this. (Corrected in round 3: the Lobster DOS parser passes no structure, so real files reach this path too, and at the round-2 head the DOS paths summed no rows there. The resolver now returns explicit row indices for every source. See Round 3.)Before and after, the O bands of SrVO3. On the left is
origin/devwith the unfiltered PROCAR andatoms=[2,3,4]. On the right is this branch with the filtered PROCAR andatoms=[2], a call that raisedValueErrorat the round-1 head. The two plots are identical.Round-2 verification
origin/dev(3ae5842) and green here:tests/pyprocar/scripts/test_filtered_procar.py(data, 11 tests) goes throughpyprocar.filterandbandsplot. An atom group's projection equals the sum of its atoms' rows in the unfiltered PROCAR (to 1e-9). The orbital sum and an orbital-filteredpcolumn match the unfiltered PROCAR the same way. A group label is0, notSr_{0}, and theo0label iso0, nots. Species selections raise.orbitals=['p']on columns namedpy pz pxdraws the same colours as their indices,orbitals=['d']on columns nameds p dthe same as index 2, andoverlay_orbitalsthere labelss,p,d.orbitals=['p']ono0 o1raises. A single orbital name raises for both header spellings. Red reasons onorigin/dev:IndexError: index 3 is out of bounds for axis 3 with size 3,IndexError: index 4 is out of bounds for axis 4 with size 3,'Sr_{0}' == '0','s' == 'o0'andKeyError: 'dx2'.tests/pyprocar/core/test_orbital_labels.pycoverso0and QE j states (red:'s' == 'o0','s,l0_j0.5_m0.5' == ...). Five cases guard the shell letters that must stay (QE, Elk, part of a shell, filtereds/p/dnames). They carryguards_existing_behaviour.tests/pyprocar/core/test_projected_layout.pyadds 2atom_groupstests (red:TypeErroron the new argument).bandsploton the atom-filtered SrVO3 PROCAR inplain,parametricwith and without atoms, andoverlay_orbitalsworks.overlay_speciesandoverlaywithitemsraise the species error. At the round-2 head,fermi2Dplainandparametricran on an atom-filteredfermi2d/non-spin-polarizedPROCAR. Round 3 makes that call raise, because the fixture holds irreducible k-points (see Round 3).guards_existing_behaviourmarker): quick suite-n 4gives 1933 passed and 2 skipped. The-m datasuite gives 400 passed and 1 skipped (round 1 had 389). basedpyright passes, after 2 baseline entries were deleted for resolver comparisons the change made necessary. Bothruff_new_violations.pygates and the F821 check pass. CI on b1a8d63: format, lint, test, typecheck and red-green pass, and red-green reportsokfor 27 added or changed tests.Round 3: the round-2 audit and live findings
The round-2 audit failed the PR on finding A. The live review passed it with a test gap, finding B. Round 3 fixes both, closes one sibling of A, and adds a guard for the interaction with #299.
ProjectionSelectionResolver.resolvereturnedatoms=()when the source had no structure.ElectronicBandStructureandFermiSurfaceread()as every row, butDensityOfStatespassed it tonp.take, which kept no rows. The Lobster DOS parser passes no structure, sodosplot(code='lobster', mode='parametric', orbitals=[1,2,3])drew an all-zero projection with no error.origin/devraisedAtom indexer is requiredthere.n_atom_rows, from the newProjectionSource.n_atoms,pyprocar/core/projection.py:206). With no atom or species selection it returns every row index explicitly (pyprocar/core/atomic_orbital_index.py:957-958). The EBS, Fermi surface and metadata callers passselection.atomsas given, so no consumer reads()as "all" any more.The selection names no atoms; select at least one atom or species(atomic_orbital_index.py:961). Onorigin/dev,compute_projected_sum(atoms=[], orbitals=[0])on a DOS returns zeros with no error (measured).spins=[]raisesThe selection names no spins; omit spins to select every channel(atomic_orbital_index.py:963). Onorigin/devthe same DOS call returns an empty array with no error (measured).orbitals=[4,5,6,7,8]reads0-1-(d). The round-2 head printed(d), andorigin/devraisedAtom indexer is required. Sources with a structure keep their species labels.== 2 * ang + 1changed to>= 1inorbital_shells) passed every test at the round-2 head. Two tests now pin it.test_two_of_three_p_orbitals_are_not_labelled_pchecks that the labels ofpyandpzreadpy,pz.test_part_of_a_shell_is_not_that_shellwrites a PROCAR withpyprocar.filter(orbital_names=['s','py','pz'])and checks thatbandsplot(orbitals=['p'])raiseshold no whole p shell. Both fail under the mutant (measured:assert 'p' == 'py,pz'andDID NOT RAISE).ibz2fbzmoves projections between atom rows by each symmetry operation's atom permutation. A row of an atom-filtered PROCAR holds a group of atoms, and the file does not record which ones. So no row permutation is known to be right.ibz2fbznow raises aValueErrorif any operation it applies moves an atom (pyprocar/core/ebs.py:2278-2288). The check runs before it copies any property. The message names the two working routes: filter the PROCAR of a full k-grid calculation (ISYM = -1), or select atoms in the plot of the unfiltered PROCAR.filter.rstsays the same. Onorigin/dev(with fix(ebs): make ibz2fbz unfold magnetic groups, phases, atoms and orbitals correctly #299) the samefermi2Dcall fails withIndexError: index 2 is out of bounds for axis 3 with size 2(ebs.py:2323). Tradeoff: a group that the symmetry maps onto itself, such as all three O atoms in one row, would unfold correctly. The file cannot show that, so pyprocar refuses instead of guessing.origin/dev5884b80 (fix(ebs): make ibz2fbz unfold magnetic groups, phases, atoms and orbitals correctly #299). InCLAUDE.mdit kept this PR's projections row and fix(ebs): make ibz2fbz unfold magnetic groups, phases, atoms and orbitals correctly #299's documented-calls row.origin/devhas since moved to f243254 (feat(verify-pyprocar): validated references and fresh status tables #297, which changes only the verify-pyprocar skill).git merge-treeagainst it is clean, so the base stays. The merged tree passes basedpyright, bothruff_new_violations.pygates and the F821 check.Round-3 verification
New tests, red on
origin/devand green at head:tests/pyprocar/core/test_dos.py:test_projected_sum_without_structure_or_atoms_sums_every_atom_row(expects 105.0 per energy) andtest_magnetization_without_structure_or_atoms_sums_every_atom_row(expects 13.5). Both are red withAtom indexer is required.test_an_empty_atom_selection_raises_instead_of_summing_nothingandtest_an_empty_spin_selection_raises_instead_of_summing_nothingare red withDID NOT RAISE.tests/pyprocar/io/lobster/test_parser.py::test_dosplot_parametric_colours_a_lobster_dos_by_every_atom(p of both atoms over every projection, 0.9). Red withAtom indexer is required.tests/pyprocar/scripts/test_filtered_procar.py(data):test_part_of_a_shell_is_not_that_shellis red withIndexError: index 3 is out of bounds for axis 4 with size 3.test_fermi2d_refuses_to_unfold_an_atom_filtered_irreducible_procaris red with theIndexErrorabove. I ran both against theorigin/devf243254 library with private fixture copies.test_two_of_three_p_orbitals_are_not_labelled_ppasses onorigin/dev. It carriesguards_existing_behaviour, because the fixed table never calledpyandpza p shell either.Gates at 625821d, through
verify.sh exec:pytest tests -m "not data" -n 4pytest tests -m data -n 4ruff_new_violations.py check origin/dev(merged tree)ruff_new_violations.py format origin/dev(merged tree)ruff check --select F821,F822,F823,NPY201 .(merged tree)red_green.py origin/devgh pr checks 298The E501 failure in an earlier CI lint run (a guard reason line) is fixed in cca79e0. CI lint passes at 625821d.
fix(warnings): show user-facing warnings through warnings.warn #294 is still open, so the Abinit
user_logger.warningcall stays. It needs converting if fix(warnings): show user-facing warnings through warnings.warn #294 merges first.Closes #293. Refs #219, #220.