graspkit-atomic 3.4.1__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.

Potentially problematic release.


This version of graspkit-atomic might be problematic. Click here for more details.

Files changed (43) hide show
  1. graspkit/CSFs_processor/__init__.py +56 -0
  2. graspkit/CSFs_processor/coupling.py +386 -0
  3. graspkit/CSFs_processor/extraction.py +129 -0
  4. graspkit/CSFs_processor/selection.py +298 -0
  5. graspkit/CSFs_processor/validation.py +230 -0
  6. graspkit/__init__.py +11 -0
  7. graspkit/data_IO/__init__.py +43 -0
  8. graspkit/data_IO/file_locator.py +135 -0
  9. graspkit/data_IO/loaders/__init__.py +31 -0
  10. graspkit/data_IO/loaders/base_loader.py +114 -0
  11. graspkit/data_IO/loaders/binary_file_loader.py +370 -0
  12. graspkit/data_IO/loaders/energy_file_loader.py +150 -0
  13. graspkit/data_IO/loaders/gj_factor_loader.py +185 -0
  14. graspkit/data_IO/loaders/hyperfine_structure_loader.py +217 -0
  15. graspkit/data_IO/loaders/lsj_comp_loader.py +259 -0
  16. graspkit/data_IO/loaders/mix_coef_loader.py +261 -0
  17. graspkit/data_IO/loaders/radial_analysis_loader.py +134 -0
  18. graspkit/data_IO/loaders/radial_wavefunction_loader.py +280 -0
  19. graspkit/data_IO/loaders/transition_loader.py +811 -0
  20. graspkit/data_IO/mix_coef_writer.py +90 -0
  21. graspkit/data_IO/produced_data_writor.py +129 -0
  22. graspkit/grasp_data_extractor/__init__.py +56 -0
  23. graspkit/grasp_data_extractor/asfs_data_processor.py +705 -0
  24. graspkit/grasp_data_extractor/radial_analysis.py +523 -0
  25. graspkit/grasp_data_extractor/radial_wavefunction_processor.py +71 -0
  26. graspkit/grasp_data_extractor/rmix_data_processor.py +422 -0
  27. graspkit/grasp_data_extractor/transition_data_processor.py +407 -0
  28. graspkit/py.typed +1 -0
  29. graspkit/utils/__init__.py +30 -0
  30. graspkit/utils/data_modules.py +105 -0
  31. graspkit/utils/environment_config.py +271 -0
  32. graspkit/utils/quadrupole_deformation.py +72 -0
  33. graspkit/utils/tool_function.py +91 -0
  34. graspkit/version.py +3 -0
  35. graspkit_atomic-3.4.1.dist-info/METADATA +167 -0
  36. graspkit_atomic-3.4.1.dist-info/RECORD +43 -0
  37. graspkit_atomic-3.4.1.dist-info/WHEEL +4 -0
  38. graspkit_atomic-3.4.1.dist-info/licenses/LICENSE +675 -0
  39. graspkit_plot/__init__.py +55 -0
  40. graspkit_plot/fig_settings.py +1286 -0
  41. graspkit_plot/mid_coupling.py +300 -0
  42. graspkit_plot/plot_functions.py +801 -0
  43. graspkit_plot/radial_analysis.py +180 -0
@@ -0,0 +1,298 @@
1
+ # -*- encoding: utf-8 -*-
2
+ """Deterministic and random CSF selection primitives."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import math
7
+ import random
8
+
9
+ import numpy as np
10
+ from numpy.typing import NDArray
11
+ import polars as pl
12
+
13
+ from ..grasp_data_extractor.rmix_data_processor import (
14
+ RmixCiSquaredData,
15
+ ci_squared,
16
+ filter_ci_scores_by_threshold,
17
+ sort_ci_scores,
18
+ )
19
+ from ..utils.data_modules import MixCoefficientData
20
+ from .validation import normalize_asf_row_indices, validate_selection_idxs
21
+
22
+
23
+ def select_csf_indices_above_ci_squared_cutoff(
24
+ coefficients: np.ndarray,
25
+ *,
26
+ ci_squared_cutoff: float = 0.1,
27
+ ) -> NDArray[np.int64]:
28
+ """Return CSF indices above a CI-square cutoff, highest score first."""
29
+ coefficient_array = np.asarray(coefficients, dtype=np.float64)
30
+ if coefficient_array.ndim != 1:
31
+ raise ValueError("coefficients must be a one-dimensional array")
32
+
33
+ squared_scores = ci_squared(coefficient_array)
34
+ indices = filter_ci_scores_by_threshold(
35
+ squared_scores,
36
+ threshold=ci_squared_cutoff,
37
+ )
38
+ if indices.size == 0:
39
+ return np.array([], dtype=np.int64)
40
+ return indices[np.argsort(-squared_scores[indices])].astype(np.int64, copy=False)
41
+
42
+
43
+ def select_csf_indices_by_ci_squared_cutoff(
44
+ asfs_mix_data: MixCoefficientData,
45
+ *,
46
+ asf_row_indices: list[list[int]] | None = None,
47
+ ci_squared_cutoff: float = 0.1,
48
+ ) -> dict[int, NDArray[np.int64]]:
49
+ """Select the union of CSF columns above a CI-square cutoff per block."""
50
+ result: dict[int, NDArray[np.int64]] = {}
51
+
52
+ normalized_rows = normalize_asf_row_indices(asfs_mix_data, asf_row_indices)
53
+
54
+ for block, selected_rows in zip(
55
+ asfs_mix_data.blocks, normalized_rows, strict=True
56
+ ):
57
+ block_data = block.mix_coefficients[selected_rows]
58
+
59
+ squared_scores = ci_squared(block_data)
60
+ score_matrix = (
61
+ squared_scores
62
+ if squared_scores.ndim == 2
63
+ else np.atleast_2d(squared_scores)
64
+ )
65
+
66
+ above_cutoff_mask = np.any(score_matrix > ci_squared_cutoff, axis=0)
67
+ result[block.block_index] = np.flatnonzero(above_cutoff_mask).astype(
68
+ np.int64, copy=False
69
+ )
70
+
71
+ return result
72
+
73
+
74
+ def sort_csfs_by_mix_coefficient(
75
+ csfs_block: list[list[str]],
76
+ mix_coefficients: np.ndarray,
77
+ ci_coefficient_cutoff: float | None = None,
78
+ ) -> list[list[str]]:
79
+ """Sort CSFs by the summed square of their mixing coefficients.
80
+
81
+ Args:
82
+ csfs_block: CSF records in one block.
83
+ mix_coefficients: 1D (single ASF) or 2D (multiple ASFs) coefficient
84
+ array whose last axis matches ``csfs_block``.
85
+ ci_coefficient_cutoff: Optional CI coefficient cutoff. When provided,
86
+ only CSFs whose combined CI-square is above its square are kept.
87
+
88
+ Returns:
89
+ CSF records sorted by descending combined squared coefficient.
90
+
91
+ Raises:
92
+ ValueError: If the CSF block or coefficient array is empty, or if their
93
+ lengths do not match.
94
+ """
95
+ if len(csfs_block) == 0 or len(mix_coefficients) == 0:
96
+ raise ValueError("CSFs_block和mix_coefficients不能为空")
97
+
98
+ coeff_array = np.atleast_2d(np.asarray(mix_coefficients))
99
+ if coeff_array.shape[-1] != len(csfs_block):
100
+ raise ValueError("mix_coefficients长度必须与CSFs_block匹配")
101
+
102
+ squared_coefficients = ci_squared(coeff_array)
103
+ combined_coeff: NDArray[np.float64] = np.asarray(
104
+ np.sum(squared_coefficients, axis=0, dtype=np.float64),
105
+ dtype=np.float64,
106
+ )
107
+ sorted_idxs, _ = sort_ci_scores(combined_coeff)
108
+
109
+ if ci_coefficient_cutoff is not None:
110
+ threshold_idxs = filter_ci_scores_by_threshold(
111
+ combined_coeff,
112
+ ci_coefficient_cutoff**2,
113
+ )
114
+ sorted_idxs = sorted_idxs[np.isin(sorted_idxs, threshold_idxs)]
115
+
116
+ return [csfs_block[int(idx)] for idx in sorted_idxs]
117
+
118
+
119
+ def generate_unique_random_numbers(max_num: int, count: int) -> list[int]:
120
+ """Generate unique random positive integers.
121
+
122
+ Args:
123
+ max_num: Inclusive upper bound for generated numbers.
124
+ count: Number of unique values to generate.
125
+
126
+ Returns:
127
+ List of unique sampled integers in the range ``[1, max_num]``.
128
+ """
129
+ number: list[int] = random.sample(range(1, max_num + 1), count)
130
+ return number
131
+
132
+
133
+ def random_choose_csfs(
134
+ block_csfs_list: list[list[str]],
135
+ *,
136
+ ratio: float | None = None,
137
+ target_count: int | None = None,
138
+ selected_csf_indices: list[int] | None = None,
139
+ rng: np.random.Generator | None = None,
140
+ ) -> tuple[list[list[str]], NDArray[np.int64], NDArray[np.int64]]:
141
+ """Randomly choose additional CSFs from a block.
142
+
143
+ Args:
144
+ block_csfs_list: Candidate CSFs in one block.
145
+ ratio: Fraction of the block to select, in ``[0, 1]``.
146
+ target_count: Absolute number of CSFs to select.
147
+ selected_csf_indices: Indices that have already been selected.
148
+ rng: Optional NumPy generator for reproducible sampling.
149
+
150
+ Returns:
151
+ Tuple of selected CSF records, selected indices, and unselected indices.
152
+
153
+ Raises:
154
+ ValueError: If exactly one target is not supplied or an input is invalid.
155
+ """
156
+ if (ratio is None) == (target_count is None):
157
+ raise ValueError("exactly one of ratio or target_count must be provided")
158
+ generator = rng or np.random.default_rng()
159
+
160
+ block_csfs_num = len(block_csfs_list)
161
+ if ratio is not None:
162
+ if not math.isfinite(ratio) or not 0 <= ratio <= 1:
163
+ raise ValueError("ratio must be finite and within [0, 1]")
164
+ total_needed = math.ceil(block_csfs_num * ratio)
165
+ else:
166
+ if type(target_count) is not int or target_count < 0:
167
+ raise ValueError("target_count must be a non-negative integer")
168
+ total_needed = target_count
169
+ if total_needed > block_csfs_num:
170
+ raise ValueError("selection target cannot exceed the CSF block size")
171
+
172
+ selected_indices = validate_selection_idxs(
173
+ np.asarray(selected_csf_indices or [], dtype=np.int64),
174
+ row_count=block_csfs_num,
175
+ )
176
+ selected_csfs_num = int(selected_indices.size)
177
+ if selected_csfs_num > total_needed:
178
+ raise ValueError("preselected CSF count exceeds the selection target")
179
+
180
+ choose_csfs_num = max(0, total_needed - selected_csfs_num)
181
+
182
+ all_idxs = np.arange(block_csfs_num, dtype=np.int64)
183
+
184
+ if selected_csfs_num > 0:
185
+ selected_set = set(selected_indices.tolist())
186
+ unselected_mask = ~np.isin(all_idxs, list(selected_set))
187
+ unselected_idxs = all_idxs[unselected_mask]
188
+
189
+ if choose_csfs_num > 0:
190
+ random_idxs = generator.choice(
191
+ unselected_idxs, size=choose_csfs_num, replace=False
192
+ )
193
+ chosen_csfs_idxs = np.concatenate(
194
+ [selected_indices, random_idxs]
195
+ )
196
+ else:
197
+ chosen_csfs_idxs = selected_indices
198
+ else:
199
+ chosen_csfs_idxs = generator.choice(
200
+ all_idxs, size=total_needed, replace=False
201
+ )
202
+
203
+ unselected_idxs = np.setdiff1d(all_idxs, chosen_csfs_idxs)
204
+
205
+ chosen_csfs: list[list[str]] = [block_csfs_list[idx] for idx in chosen_csfs_idxs]
206
+
207
+ return chosen_csfs, chosen_csfs_idxs, unselected_idxs
208
+
209
+
210
+ def select_csfs_rows(
211
+ csfs_df: pl.DataFrame,
212
+ idxs: np.ndarray,
213
+ *,
214
+ allow_duplicates: bool = False,
215
+ ) -> pl.DataFrame:
216
+ """Select CSF rows from a DataFrame under the strict index contract.
217
+
218
+ Args:
219
+ csfs_df: DataFrame with one row per CSF.
220
+ idxs: Row indices to select.
221
+ allow_duplicates: If False (default), duplicate indices are rejected.
222
+
223
+ Returns:
224
+ The selected rows, in ``idxs`` order.
225
+
226
+ Raises:
227
+ ValueError: If ``idxs`` fails :func:`validation.validate_selection_idxs`.
228
+ """
229
+ valid_idxs = validate_selection_idxs(
230
+ idxs,
231
+ row_count=csfs_df.height,
232
+ allow_duplicates=allow_duplicates,
233
+ )
234
+ return csfs_df[valid_idxs]
235
+
236
+
237
+ def _unique_preserve_order(idxs: NDArray[np.int64]) -> NDArray[np.int64]:
238
+ seen: set[int] = set()
239
+ ordered: list[int] = []
240
+ for idx in idxs:
241
+ idx_int = int(idx)
242
+ if idx_int in seen:
243
+ continue
244
+ seen.add(idx_int)
245
+ ordered.append(idx_int)
246
+ return np.array(ordered, dtype=np.int64)
247
+
248
+
249
+ def rmix_cumulative_selected_row_idxs(
250
+ rmix_ci_squared: RmixCiSquaredData,
251
+ cumulative_threshold: float,
252
+ ) -> NDArray[np.int64]:
253
+ """Select CSF row indices whose cumulative CI-square contribution is kept.
254
+
255
+ Selected per-ASF CSF indices are unioned across all selected ASFs and all
256
+ blocks, then offset by each block's CSF count so the result indexes
257
+ directly into a concatenated (all-blocks) CSF row space. Order is
258
+ preserved from the descending CI-square ranking (most important CSF
259
+ first), not sorted by row index.
260
+
261
+ Args:
262
+ rmix_ci_squared: Parsed rmix CI-square data, one 2D array per block
263
+ (ASF rows by CSF columns).
264
+ cumulative_threshold: Cumulative CI-square fraction to keep, in
265
+ ``(0, 1]``.
266
+
267
+ Returns:
268
+ Duplicate-free row indices into the concatenated CSF space, ordered
269
+ by descending CI-square importance.
270
+
271
+ Raises:
272
+ ValueError: If no block/ASF selects any CSF.
273
+ """
274
+ selected_by_block = rmix_ci_squared.filter_sorted_ci_scores_by_cumulative(
275
+ cumulative_threshold
276
+ )
277
+
278
+ mapped_by_block: list[NDArray[np.int64]] = []
279
+ block_offset = 0
280
+ for block_ci_indices, block_ci_squared in zip(
281
+ selected_by_block.csf_indices_list,
282
+ rmix_ci_squared.ci_squared_list,
283
+ strict=True,
284
+ ):
285
+ block_selected = [
286
+ np.asarray(asf_ci_indices, dtype=np.int64)
287
+ for asf_ci_indices in block_ci_indices
288
+ if len(asf_ci_indices) > 0
289
+ ]
290
+ if block_selected:
291
+ block_union = _unique_preserve_order(np.concatenate(block_selected))
292
+ mapped_by_block.append(block_union + block_offset)
293
+
294
+ block_offset += int(block_ci_squared.shape[1])
295
+
296
+ if not mapped_by_block:
297
+ raise ValueError("rmix 累计贡献筛选没有选出任何 CSF")
298
+ return _unique_preserve_order(np.concatenate(mapped_by_block))
@@ -0,0 +1,230 @@
1
+ # -*- encoding: utf-8 -*-
2
+ """Strict data-contract validation for CSF selection indices, headers, and paths.
3
+
4
+ Every check here fails fast with a locatable error instead of silently
5
+ truncating, filtering, or padding data. Callers must not catch these errors
6
+ to fall back to partial results.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from collections.abc import Iterable, Sequence
12
+ from pathlib import Path
13
+
14
+ import numpy as np
15
+ from numpy.typing import NDArray
16
+
17
+ from ..utils.data_modules import MixCoefficientData
18
+
19
+
20
+ def validate_selection_idxs(
21
+ idxs: np.ndarray,
22
+ *,
23
+ row_count: int | None = None,
24
+ allow_duplicates: bool = False,
25
+ source: str | Path | None = None,
26
+ ) -> NDArray[np.int64]:
27
+ """Validate a selection index array under a strict data contract.
28
+
29
+ Args:
30
+ idxs: Candidate index array.
31
+ row_count: If given, every index must fall in ``[0, row_count)``.
32
+ allow_duplicates: If False (default), duplicate indices are rejected.
33
+ source: Optional label (e.g. a file path) included in error messages.
34
+
35
+ Returns:
36
+ The indices as a one-dimensional ``int64`` array, in their original
37
+ order.
38
+
39
+ Raises:
40
+ ValueError: If ``idxs`` is not a one-dimensional integer-kind array,
41
+ or contains negative, out-of-range, or (unless allowed)
42
+ duplicate values.
43
+ """
44
+ label = f" ({source})" if source is not None else ""
45
+ array = np.asarray(idxs)
46
+ if array.ndim != 1:
47
+ raise ValueError(f"选择索引必须是一维数组{label}: ndim={array.ndim}")
48
+ if array.dtype.kind not in ("i", "u"):
49
+ raise ValueError(f"选择索引必须是整数 dtype{label}: 实际 dtype={array.dtype}")
50
+
51
+ int_array = array.astype(np.int64, copy=False)
52
+ if int_array.size == 0:
53
+ return int_array
54
+
55
+ min_value = int(int_array.min())
56
+ if min_value < 0:
57
+ raise ValueError(f"选择索引不能为负数{label}: min={min_value}")
58
+
59
+ if row_count is not None:
60
+ max_value = int(int_array.max())
61
+ if max_value >= row_count:
62
+ raise ValueError(
63
+ f"选择索引越界{label}: max={max_value}, row_count={row_count}"
64
+ )
65
+
66
+ if not allow_duplicates:
67
+ unique_count = int(np.unique(int_array).shape[0])
68
+ if unique_count != int_array.shape[0]:
69
+ raise ValueError(
70
+ f"选择索引包含重复值{label}: 共 {int_array.shape[0]} 项,去重后 {unique_count} 项"
71
+ )
72
+
73
+ return int_array
74
+
75
+
76
+ def load_selection_idxs(
77
+ idx_file: Path,
78
+ *,
79
+ row_count: int | None = None,
80
+ allow_duplicates: bool = False,
81
+ ) -> NDArray[np.int64]:
82
+ """Load and strictly validate a ``.npy`` selection index file.
83
+
84
+ Args:
85
+ idx_file: Path to a ``.npy`` file containing a 1D integer index array.
86
+ row_count: If given, every index must fall in ``[0, row_count)``.
87
+ allow_duplicates: If False (default), duplicate indices are rejected.
88
+
89
+ Returns:
90
+ The indices as a one-dimensional ``int64`` array.
91
+
92
+ Raises:
93
+ FileNotFoundError: If ``idx_file`` does not exist.
94
+ ValueError: If the loaded array fails :func:`validate_selection_idxs`.
95
+ """
96
+ if not idx_file.is_file():
97
+ raise FileNotFoundError(f"idx 文件不存在: {idx_file}")
98
+ loaded = np.load(idx_file, allow_pickle=False)
99
+ return validate_selection_idxs(
100
+ loaded,
101
+ row_count=row_count,
102
+ allow_duplicates=allow_duplicates,
103
+ source=idx_file,
104
+ )
105
+
106
+
107
+ def validate_header_lines(header_lines: Sequence[object]) -> list[str]:
108
+ """Validate that a CSF header is exactly 5 string lines.
109
+
110
+ Raises:
111
+ ValueError: If ``header_lines`` is not a sequence of exactly 5
112
+ strings.
113
+ """
114
+ if not isinstance(header_lines, (list, tuple)):
115
+ raise ValueError("CSFs header 必须是字符串列表")
116
+
117
+ validated_lines: list[str] = []
118
+ for line in header_lines:
119
+ if not isinstance(line, str):
120
+ raise ValueError("CSFs header 必须是字符串列表")
121
+ validated_lines.append(line)
122
+
123
+ if len(validated_lines) != 5:
124
+ raise ValueError(f"CSFs header 必须是 5 行: 实际 {len(validated_lines)} 行")
125
+ return validated_lines
126
+
127
+
128
+ def validate_headers_match(
129
+ all_header_lines: Sequence[Sequence[str]],
130
+ *,
131
+ labels: Sequence[str | None] | None = None,
132
+ ) -> list[str]:
133
+ """Validate that every source's header lines are identical.
134
+
135
+ Args:
136
+ all_header_lines: One header-line sequence per source.
137
+ labels: Optional per-source labels used to identify a mismatch.
138
+
139
+ Returns:
140
+ The shared header lines.
141
+
142
+ Raises:
143
+ ValueError: If ``all_header_lines`` is empty, or any entry differs
144
+ from the first.
145
+ """
146
+ if not all_header_lines:
147
+ raise ValueError("没有可比较的 CSFs header")
148
+
149
+ def _label(index: int) -> str:
150
+ if labels is not None and index < len(labels) and labels[index] is not None:
151
+ return str(labels[index])
152
+ return f"#{index}"
153
+
154
+ reference_header = validate_header_lines(all_header_lines[0])
155
+ for index, header_lines in enumerate(all_header_lines[1:], start=1):
156
+ current_header = validate_header_lines(header_lines)
157
+ if current_header != reference_header:
158
+ raise ValueError(
159
+ f"多个 CSFs 来源的 header 不一致: {_label(0)} 与 {_label(index)} 的 header_lines 不同"
160
+ )
161
+ return reference_header
162
+
163
+
164
+ def validate_output_path_disjoint(
165
+ output_path: Path,
166
+ input_paths: Iterable[Path | None],
167
+ ) -> None:
168
+ """Validate that ``output_path`` does not resolve to any input path.
169
+
170
+ Raises:
171
+ ValueError: If ``output_path`` equals any non-``None`` entry in
172
+ ``input_paths`` once both are resolved.
173
+ """
174
+ resolved_output = Path(output_path).resolve()
175
+ for input_path in input_paths:
176
+ if input_path is None:
177
+ continue
178
+ if Path(input_path).resolve() == resolved_output:
179
+ raise ValueError(f"输出路径与输入路径冲突: {output_path} == {input_path}")
180
+
181
+
182
+ def validate_coupling_level(coupling_level: int | None) -> int | None:
183
+ """Validate that ``coupling_level`` is ``None`` or a positive integer.
184
+
185
+ Raises:
186
+ ValueError: If ``coupling_level`` is given and not positive.
187
+ """
188
+ if coupling_level is not None and (
189
+ type(coupling_level) is not int or coupling_level <= 0
190
+ ):
191
+ raise ValueError(f"coupling_level 必须是 None 或正整数: {coupling_level}")
192
+ return coupling_level
193
+
194
+
195
+ def normalize_asf_row_indices(
196
+ asfs_mix_data: MixCoefficientData,
197
+ asf_row_indices: Sequence[Sequence[int]] | None,
198
+ ) -> list[list[int]]:
199
+ """Normalize and validate ASF matrix row indices for every rmix block."""
200
+ if asf_row_indices is None:
201
+ normalized_row_indices = [
202
+ block.asf_row_indices.tolist()
203
+ for block in asfs_mix_data.blocks
204
+ ]
205
+ else:
206
+ normalized_row_indices = [
207
+ [int(row_index) for row_index in block] for block in asf_row_indices
208
+ ]
209
+ if len(normalized_row_indices) != len(asfs_mix_data.blocks):
210
+ raise ValueError(
211
+ "asf_row_indices 第一层长度与 mixing coefficient block 数量不一致"
212
+ )
213
+
214
+ for block, row_indices in zip(asfs_mix_data.blocks, normalized_row_indices, strict=True):
215
+ if not row_indices:
216
+ raise ValueError(f"Block {block.block_index}: asf_row_indices 不能为空")
217
+ if len(row_indices) != len(set(row_indices)):
218
+ raise ValueError(
219
+ f"Block {block.block_index}: asf_row_indices 包含重复值"
220
+ )
221
+ if block.mix_coefficients.ndim != 2:
222
+ raise ValueError(
223
+ f"Block {block.block_index}: mixing coefficients 必须是二维矩阵"
224
+ )
225
+ if any(
226
+ row_index < 0 or row_index >= block.mix_coefficients.shape[0]
227
+ for row_index in row_indices
228
+ ):
229
+ raise ValueError(f"Block {block.block_index}: asf_row_indices 越界")
230
+ return normalized_row_indices
graspkit/__init__.py ADDED
@@ -0,0 +1,11 @@
1
+ # -*- encoding: utf-8 -*-
2
+ """Stable GRASP data I/O, processing, and plotting foundation."""
3
+
4
+ from .version import __version__
5
+
6
+ __author__ = "YenochQin (秦毅)"
7
+
8
+ __all__ = [
9
+ "__author__",
10
+ "__version__",
11
+ ]
@@ -0,0 +1,43 @@
1
+ # -*- encoding: utf-8 -*-
2
+ from .loaders.base_loader import BaseLoader # noqa: F401
3
+ from .loaders.binary_file_loader import BinaryFileLoader # noqa: F401
4
+ from .loaders.energy_file_loader import EnergyFileLoader # noqa: F401
5
+ from .loaders.gj_factor_loader import GJFactorLoader # noqa: F401
6
+ from .loaders.hyperfine_structure_loader import ( # noqa: F401
7
+ HyperfineStructureLoader,
8
+ NuclearParameters,
9
+ )
10
+ from .loaders.lsj_comp_loader import LSJCompLoader # noqa: F401
11
+ from .loaders.mix_coef_loader import MixCoefLoader # noqa: F401
12
+ from .loaders.radial_wavefunction_loader import ( # noqa: F401
13
+ RWFNFileLoader,
14
+ RWFNOrbitalData,
15
+ )
16
+ from .loaders.transition_loader import TransitionLoader # noqa: F401
17
+ from .mix_coef_writer import write_mix_coefficient_block
18
+ from .produced_data_writor import (
19
+ csfs_header_path_for_parquet,
20
+ load_csfs_header_lines,
21
+ write_csfs_blocks_to_cfile,
22
+ )
23
+
24
+ # 显式导出所有需要的函数
25
+ __all__ = [
26
+ # New loader classes
27
+ "BaseLoader",
28
+ "BinaryFileLoader",
29
+ "EnergyFileLoader",
30
+ "GJFactorLoader",
31
+ "HyperfineStructureLoader",
32
+ "NuclearParameters",
33
+ "LSJCompLoader",
34
+ "MixCoefLoader",
35
+ "RWFNFileLoader",
36
+ "RWFNOrbitalData",
37
+ "TransitionLoader",
38
+ "write_mix_coefficient_block",
39
+ # produced_data_write
40
+ "csfs_header_path_for_parquet",
41
+ "load_csfs_header_lines",
42
+ "write_csfs_blocks_to_cfile",
43
+ ]