Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) Make bias statistics complete for all elements #4496

Open
wants to merge 93 commits into
base: devel
Choose a base branch
from

Conversation

SumGuo-88
Copy link
Collaborator

@SumGuo-88 SumGuo-88 commented Dec 23, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a method to identify and count unique element types in datasets.
    • Added new parameters for enhanced control over statistics collection in training configurations.
    • Expanded dataset of chemical elements for improved mixed-type data processing.
    • Added command-line options to skip element checks and specify minimum frames during statistical data retrieval.
  • Bug Fixes

    • Improved error handling and reporting for type mapping issues in dataset loading.
  • Tests

    • Added unit tests for the make_stat_input function to ensure accurate processing of atomic types.
    • Created a new test file for comprehensive testing of statistical input functionality.

Copy link
Contributor

coderabbitai bot commented Dec 23, 2024

📝 Walkthrough

Walkthrough

The pull request introduces modifications in the DeepMD-kit's PyTorch utility modules. A new public method get_frame_index is added to the DeepmdDataSetForLoader class in dataset.py, which retrieves frame indices and counts for each unique element in the dataset. The make_stat_input function in stat.py is updated to include new parameters for enhanced handling of atomic types. A new test file is created to validate the functionality of make_stat_input. Additionally, attributes related to statistical calculations are added to the Trainer class, and error handling is improved in the data.py methods.

Changes

File Change Summary
deepmd/pt/utils/dataset.py Added public method get_frame_index() to retrieve frame indices and counts for unique elements. Minor corrections made in the constructor's docstring.
deepmd/pt/utils/stat.py Updated make_stat_input() function to include min_frames_per_element_forstat and enable_element_completion parameters, with enhanced logic for atomic types and statistics handling.
source/tests/pt/test_make_stat_input.py Introduced unit tests for make_stat_input, including class TestMakeStatInput with relevant test methods.
deepmd/pt/train/training.py Added attributes min_frames_per_element_forstat and enable_element_completion to the Trainer class, initialized with default values.
deepmd/utils/argcheck.py Added optional argument min_frames_per_element_forstat and required argument enable_element_completion to the training configuration.
deepmd/utils/data.py Modified error handling in _load_set and _load_type_mix methods to improve robustness and error reporting.
source/tests/pt/mixed_type_data/sys.000000/type_map.raw Added new entries for chemical elements, expanding the dataset for mixed-type data processing.
deepmd/main.py Introduced new command-line argument --skip-elementcheck to the change-bias parser for enhanced flexibility.
deepmd/pt/entrypoints/main.py Updated change_bias function to include a new parameter elem_check_stat for controlling element completion during bias adjustments.

Possibly related PRs

  • refactor: refactor update_sel and save min_nbor_dist #3829: The changes in this PR involve modifications to the update_sel method to include a type_map parameter, which is relevant to the handling of atomic types and statistics, similar to the get_frame_index method introduced in the main PR that deals with counting frames for unique elements in the dataset.
  • fix(pt): set weights_only=True for torch.load #4147: This PR addresses the loading of model weights with the weights_only=True parameter, which may relate to the handling of data structures in the main PR that involves loading and processing datasets, ensuring that only necessary data is loaded for efficiency.
  • feat(pt): train with energy Hessian #4169: The introduction of Hessian-related functionality in this PR aligns with the main PR's focus on enhancing data handling and processing, particularly in the context of managing complex data structures like those involving mixed types and their statistics.

Suggested labels

Docs

Suggested reviewers

  • njzjz
  • wanghan-iapcm
  • iProzd

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73a20b0 and c05ffb1.

📒 Files selected for processing (2)
  • deepmd/main.py (1 hunks)
  • deepmd/pt/entrypoints/main.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • deepmd/main.py
  • deepmd/pt/entrypoints/main.py
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (c-cpp)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
deepmd/pt/utils/stat.py (1)

110-119: Avoid potential index-out-of-range errors when concatenating Tensors.
The code checks “isinstance(sys_stat[key], list) and isinstance(sys_stat[key][0], torch.Tensor)” without verifying that the list is non-empty. This might raise an IndexError if the list is empty. Consider adding a length check before accessing sys_stat[key][0].

Possible safe check:

-if isinstance(sys_stat[key], list) and isinstance(sys_stat[key][0], torch.Tensor):
+if isinstance(sys_stat[key], list) and len(sys_stat[key]) > 0 \
+   and isinstance(sys_stat[key][0], torch.Tensor):
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cfe17a3 and 32da243.

📒 Files selected for processing (2)
  • deepmd/pt/utils/dataset.py (1 hunks)
  • deepmd/pt/utils/stat.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
deepmd/pt/utils/dataset.py

44-44: SyntaxError: Expected an indented block after function definition

🔇 Additional comments (3)
deepmd/pt/utils/stat.py (3)

91-96: Validate 'atype' presence and handle empty arrays gracefully.
While updating the collected elements, consider explicitly checking that each 'atype' array is non-empty. If a dataset yields an empty array, it might bypass your missing-elements logic.

✅ Verification successful

Let me gather more information about how atype is handled in the codebase.


Let me try again with the correct file type flag for ripgrep.


Based on the code analysis, I can now generate the final response:

Empty arrays are handled safely by numpy.unique and set.update
The code uses numpy.unique() which safely handles empty arrays by returning an empty array, and set.update() which safely handles empty iterables. The logic for missing elements works correctly even with empty arrays since an empty array's unique values would simply not add any elements to the set.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for patterns related to 'atype' handling and array emptiness checks
rg -A 3 "atype" --type python

# Also look for the specific class/function containing this code
ast-grep --pattern $'def $_(self, $_):
    $$$
    collected_elements = set()
    for sys_stat in lst:
        if "atype" in sys_stat:
            collected_elements.update($$$)
    $$$'

Length of output: 248


Script:

#!/bin/bash
# Search for patterns related to 'atype' handling and array emptiness checks
rg -A 3 "atype" -t py

# Look for similar array handling patterns in the codebase
rg -t py "numpy\.unique|\.update.*numpy" -A 2

# Find the specific file we're analyzing
fd "stat.py" --type f

Length of output: 89317


85-90: Consider using logging and verifying that all datasets are included.
You are only collecting the set of elements from the first dataset and simply printing them. If your intent is to gather possible elements across all datasets, you may want to iterate over all datasets. Also, using "log.info" would be more consistent than a raw "print" in a library setting.

Possible fix for the print statement:

-        print('we want', all_elements)
+        log.info(f"We want elements: {all_elements}")

97-109: Ensure partial coverage logic for missing elements is intended.
Here, frames are appended until the number of records reaches 'nbatches'. Verify that the short-circuiting with “break” actually meets your coverage needs for missing elements. If your goal is to gather as many frames as possible across all missing elements, you might need a more explicit limit or a different approach.

✅ Verification successful

Let me gather more context about this code to better understand the coverage logic for missing elements.


Let me search for more context about the initialization and usage of nbatches to better understand the coverage requirements.


Let me search for the initialization of nbatches to understand its purpose in the coverage logic.


Let me search for more context about how nbatches is used and its relationship with the dataset statistics.


Based on the gathered context, I can now provide a final response about the coverage logic for missing elements.

The current partial coverage logic is intentional and correct.

The code's behavior is appropriate because:

  1. nbatches is a parameter that defines the desired number of batches for collecting statistics, used consistently throughout the make_stat_input function
  2. The break condition if len(lst[i]['atype']) >= nbatches ensures each system collects up to the specified number of batches, preventing over-sampling
  3. This is consistent with how regular batches are collected earlier in the function where numb_batches = min(nbatches, len(dataloaders[i])) is used
  4. The goal is to gather a statistically significant sample (controlled by nbatches) rather than exhaustively processing all frames containing missing elements

The current implementation correctly balances between gathering sufficient data for statistics while maintaining consistent batch sizes across all elements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Let's first look at the broader context of this code
rg -B 10 -A 5 "for missing_element in missing_elements" deepmd/pt/utils/stat.py

# Also search for any related tests that might help understand the intended behavior
fd "test.*stat.*py" -x rg -l "missing_element"

# Look for the initialization of nbatches and lst variables
rg -B 5 "nbatches.*=|lst.*=" deepmd/pt/utils/stat.py

Length of output: 1724


Script:

#!/bin/bash
# Search for the function definition and its parameters
ast-grep --pattern 'def $FUNC($PARAMS) {
  $$$
  nbatches
  $$$
}'  deepmd/pt/utils/stat.py

# Look for any documentation or comments about nbatches
rg -B 3 -A 3 "nbatches" deepmd/pt/utils/stat.py

# Check if there are any tests that verify this behavior
fd "test.*stat.*py" -x cat {} 

Length of output: 66294


Script:

#!/bin/bash
# Look for the function definition and documentation
rg -B 10 "def make_stat_input" deepmd/pt/utils/stat.py

# Search for any tests that verify the behavior with missing elements
rg -B 5 -A 5 "missing_element" deepmd/pt/utils/stat.py

Length of output: 1079


Script:

#!/bin/bash
# Look for the full function implementation and its docstring
rg -B 20 -A 50 "def make_stat_input" deepmd/pt/utils/stat.py

# Search for any tests that verify the statistics collection
fd "test.*stat.*py" -x rg -A 10 "make_stat_input"

# Look for the initialization of lst and how frames are collected
rg -B 5 "lst.*=.*\[\]" deepmd/pt/utils/stat.py

Length of output: 4539

deepmd/pt/utils/dataset.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
deepmd/pt/utils/stat.py (2)

89-89: Remove debug print statement.

The print statement print("we want", all_elements) appears to be debug code that should be removed or replaced with proper logging.

-        print("we want", all_elements)
+        log.debug(f"Required elements for statistics: {all_elements}")

97-111: Optimize nested loops and add error handling.

The nested loops for handling missing elements could be optimized, and error handling should be added for invalid frame indices.

         for missing_element in missing_elements:
             for i, dataset in enumerate(datasets):
                 if hasattr(dataset, "element_to_frames"):
-                    frame_indices = dataset.element_to_frames.get(
-                        missing_element, []
-                    )
+                    try:
+                        frame_indices = dataset.element_to_frames.get(missing_element, [])
+                        if not frame_indices:
+                            continue
+                            
+                        # Pre-check if we need more frames
+                        if len(lst[i]["atype"]) >= nbatches:
+                            break
+                            
+                        # Process frames in batch
+                        for frame_idx in frame_indices:
+                            frame_data = dataset[frame_idx]
+                            if any(key not in lst[i] for key in frame_data):
+                                lst[i].update({key: [] for key in frame_data if key not in lst[i]})
+                            for key in frame_data:
+                                lst[i][key].append(frame_data[key])
+                            if len(lst[i]["atype"]) >= nbatches:
+                                break
+                    except Exception as e:
+                        log.warning(f"Error processing frames for element {missing_element}: {e}")
+                        continue
-                    for frame_idx in frame_indices:
-                        if len(lst[i]["atype"]) >= nbatches:
-                            break
-                        frame_data = dataset[frame_idx]
-                        for key in frame_data:
-                            if key not in lst[i]:
-                                lst[i][key] = []
-                            lst[i][key].append(frame_data[key])
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 32da243 and adf2315.

📒 Files selected for processing (2)
  • deepmd/pt/utils/dataset.py (1 hunks)
  • deepmd/pt/utils/stat.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
deepmd/pt/utils/dataset.py

44-44: SyntaxError: Expected an indented block after function definition

🔇 Additional comments (2)
deepmd/pt/utils/dataset.py (2)

43-44: ⚠️ Potential issue

Fix the indentation error in method definition.

The method definition has incorrect indentation which will cause a SyntaxError. It should be aligned with other class methods.

-        def _build_element_to_frames(self):
-        """Mapping element types to frame indexes"""
+    def _build_element_to_frames(self):
+        """Mapping element types to frame indexes"""

Likely invalid or redundant comment.

🧰 Tools
🪛 Ruff (0.8.2)

44-44: SyntaxError: Expected an indented block after function definition


43-53: 🛠️ Refactor suggestion

Make frame limit configurable and enhance documentation.

  1. The hard-coded limit of 10 frames per element should be configurable.
  2. The docstring should be more descriptive about the method's purpose and return value.
-    def _build_element_to_frames(self):
-        """Mapping element types to frame indexes"""
+    def _build_element_to_frames(self, max_frames_per_element: int = 10) -> dict[int, list[int]]:
+        """Build a mapping of element types to their corresponding frame indices.
+        
+        Args:
+            max_frames_per_element: Maximum number of frames to store per element type.
+            
+        Returns:
+            A dictionary mapping element types (int) to lists of frame indices (list[int])
+            where each element type appears.
+        """
         element_to_frames = {element: [] for element in range(self._ntypes)}
         for frame_idx in range(len(self)):
             frame_data = self._data_system.get_item_torch(frame_idx)
 
             elements = frame_data["atype"]
             for element in set(elements):
-                if len(element_to_frames[element]) < 10:
+                if len(element_to_frames[element]) < max_frames_per_element:
                     element_to_frames[element].append(frame_idx)
         return element_to_frames

Likely invalid or redundant comment.

🧰 Tools
🪛 Ruff (0.8.2)

44-44: SyntaxError: Expected an indented block after function definition

deepmd/pt/utils/stat.py Outdated Show resolved Hide resolved
deepmd/pt/utils/dataset.py Fixed Show fixed Hide fixed
deepmd/pt/utils/stat.py Fixed Show fixed Hide fixed
@iProzd iProzd marked this pull request as draft December 24, 2024 14:37
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (4)
source/tests/pt/test_make_stat_input.py (4)

14-23: Consider using collections.defaultdict for element_to_frames.
You can simplify the nested checks for element presence in the dictionary by using a defaultdict(list), which would eliminate the need for the explicit if atype not in self.element_to_frames: condition.

-from collections import defaultdict

class TestDataset:
    def __init__(self, samples):
        self.samples = samples
-        self.element_to_frames = {}
+        from collections import defaultdict
+        self.element_to_frames = defaultdict(list)
        for idx, sample in enumerate(samples):
            atypes = sample["atype"]
            for atype in atypes:
-                if atype not in self.element_to_frames:
-                    self.element_to_frames[atype] = []
                self.element_to_frames[atype].append(idx)

25-28: Rename the property to better reflect usage.
Using @property but naming it get_all_atype can be confusing. Consider a more descriptive name like all_atypes, since Python properties typically avoid "get_" prefixes.


53-59: Remove or use the assigned lst variable.
The variable lst is assigned but never used, according to static analysis hints. Consider removing it or using it for additional assertions.

 def test_make_stat_input(self):
     nbatches = 1
-    lst = make_stat_input(self.datasets, self.dataloaders, nbatches=nbatches)
+    _ = make_stat_input(self.datasets, self.dataloaders, nbatches=nbatches)
     all_elements = self.system.get_all_atype
     unique_elements = {1, 2}
     self.assertEqual(unique_elements, all_elements, "make_stat_input miss elements")
🧰 Tools
🪛 Ruff (0.8.2)

55-55: Local variable lst is assigned to but never used

Remove assignment to unused variable lst

(F841)


61-62: Optional test runner inclusion.
Having the if __name__ == "__main__": unittest.main() block is fine. You could remove it if tests are run by a dedicated test runner.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between adf2315 and dc64307.

📒 Files selected for processing (3)
  • deepmd/pt/utils/dataset.py (4 hunks)
  • deepmd/pt/utils/stat.py (1 hunks)
  • source/tests/pt/test_make_stat_input.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
source/tests/pt/test_make_stat_input.py

55-55: Local variable lst is assigned to but never used

Remove assignment to unused variable lst

(F841)

🔇 Additional comments (4)
source/tests/pt/test_make_stat_input.py (1)

40-52: Test setup looks good.
The dataset creation for testing is straightforward and clear. No issues found.

deepmd/pt/utils/dataset.py (2)

21-24: Docstring clarity is sufficient.
The docstring effectively describes constructor parameters. No corrections needed.


34-34: Initialization of element frames is a good approach.
Storing the result of _build_element_to_frames() in self.element_to_frames and self.get_all_atype reduces redundancy.

deepmd/pt/utils/stat.py (1)

86-94: No immediate issues with collection of atomic types.
Collecting and updating sets is correct.

deepmd/pt/utils/dataset.py Outdated Show resolved Hide resolved
deepmd/pt/utils/stat.py Outdated Show resolved Hide resolved
deepmd/pt/utils/stat.py Outdated Show resolved Hide resolved
deepmd/pt/utils/stat.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
deepmd/utils/data.py (1)

667-674: Consider providing more informative error details when the type map lookup fails.
While raising IndexError is appropriate, developers might benefit from including the failing value(s). You could, for instance, collect and display the out-of-range types to provide immediate troubleshooting clues. A custom exception or a more descriptive error message can significantly improve clarity and debuggability.

Here's an example of how you might refine the exception:

            except IndexError as e:
-                raise IndexError(
-                    f"some types in 'real_atom_types.npy' of set {set_name} are not contained in {self.get_ntypes()} types!"
-                ) from e
+                # Gather all invalid elements
+                invalid_types = np.unique(real_type[(real_type < 0) | (real_type >= len(self.type_idx_map))])
+                raise IndexError(
+                    f"One or more invalid types found in 'real_atom_types.npy' of set {set_name}: {invalid_types}. "
+                    f"Ensure all types are within [0, {self.get_ntypes()-1}]."
+                ) from e
deepmd/utils/argcheck.py (1)

2829-2834: Ensure user awareness of the new argument.

The new argument min_frames_per_element_forstat is useful for controlling statistic completeness. It might be helpful to specify the expected range (e.g., must be ≥ 1) and how large values impact memory or performance overhead.

source/tests/pt/test_make_stat_input.py (1)

68-68: Remove or utilize the unused variable.

The variable lst is assigned with the result of make_stat_input(...) but never used. If no further checks are applied, remove it to keep the code clean.

-        lst = make_stat_input(
+        make_stat_input(
🧰 Tools
🪛 Ruff (0.8.2)

68-68: Local variable lst is assigned to but never used

Remove assignment to unused variable lst

(F841)

deepmd/pt/utils/stat.py (1)

188-197: Double-check sets for collected vs. missing elements.

This code block re-checks missing elements with:

missing_element = all_element - collect_elements

Confirm that the logic aligns with the earlier missing_elements sets in lines 110–111 to avoid confusion or duplication.

🧰 Tools
🪛 Ruff (0.8.2)

188-188: SyntaxError: unindent does not match any outer indentation level


189-189: SyntaxError: Unexpected indentation

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc64307 and 725f1dd.

📒 Files selected for processing (6)
  • deepmd/pt/train/training.py (2 hunks)
  • deepmd/pt/utils/dataset.py (3 hunks)
  • deepmd/pt/utils/stat.py (3 hunks)
  • deepmd/utils/argcheck.py (1 hunks)
  • deepmd/utils/data.py (1 hunks)
  • source/tests/pt/test_make_stat_input.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • deepmd/pt/utils/dataset.py
🧰 Additional context used
🪛 Ruff (0.8.2)
deepmd/pt/utils/stat.py

134-134: SyntaxError: Expected a statement


134-134: SyntaxError: Expected a statement


134-134: SyntaxError: Expected a statement


134-134: SyntaxError: Expected a statement


135-135: SyntaxError: Unexpected indentation


144-144: SyntaxError: unindent does not match any outer indentation level


144-144: SyntaxError: Expected a statement


144-144: SyntaxError: Expected a statement


144-145: SyntaxError: Expected a statement


145-145: SyntaxError: Unexpected indentation


176-176: SyntaxError: Expected a statement


176-176: SyntaxError: Expected a statement


176-176: SyntaxError: Expected a statement


176-176: SyntaxError: Expected a statement


188-188: SyntaxError: unindent does not match any outer indentation level


189-189: SyntaxError: Unexpected indentation


231-231: SyntaxError: Expected a statement


231-231: SyntaxError: Expected a statement


231-231: SyntaxError: Expected a statement


231-231: SyntaxError: Expected a statement

source/tests/pt/test_make_stat_input.py

43-43: Loop control variable idx not used within loop body

Rename unused idx to _idx

(B007)


68-68: Local variable lst is assigned to but never used

Remove assignment to unused variable lst

(F841)

🔇 Additional comments (4)
deepmd/pt/train/training.py (2)

145-147: Add type check or validation for the statistic threshold.

While setting self.min_frames_per_element_forstat, consider ensuring it's a strictly positive integer. If a negative or zero value is passed, it may cause runtime issues or meaningless statistics.


232-232: Parameter usage looks correct.

Passing self.min_frames_per_element_forstat to make_stat_input aligns with the newly introduced functionality. Just be sure to verify that all call sites expect this parameter and properly handle out-of-range values.

source/tests/pt/test_make_stat_input.py (1)

41-50: Optimize loop variable usage.

The static analysis hint suggests renaming _idx if it were truly unused, but here idx is used to assign frames. The accusations of an unused loop variable are false. You can safely ignore that static analysis hint.

🧰 Tools
🪛 Ruff (0.8.2)

43-43: Loop control variable idx not used within loop body

Rename unused idx to _idx

(B007)

deepmd/pt/utils/stat.py (1)

52-110: Confirm correctness of cumulative element count logic.

You aggregate total_element_counts[elem]["count"], but also track indices. Ensure you don’t exceed list boundaries when collecting indices for up to min_frames_per_element_forstat. If more frames exist, consider whether you need them to fulfill certain statistics.

deepmd/pt/utils/stat.py Outdated Show resolved Hide resolved
deepmd/pt/utils/stat.py Outdated Show resolved Hide resolved
deepmd/pt/utils/dataset.py Outdated Show resolved Hide resolved
deepmd/pt/utils/dataset.py Outdated Show resolved Hide resolved
deepmd/pt/utils/stat.py Outdated Show resolved Hide resolved
deepmd/pt/utils/dataset.py Outdated Show resolved Hide resolved
deepmd/pt/utils/dataset.py Outdated Show resolved Hide resolved
deepmd/pt/utils/stat.py Outdated Show resolved Hide resolved
deepmd/pt/utils/stat.py Outdated Show resolved Hide resolved
deepmd/pt/utils/stat.py Outdated Show resolved Hide resolved
source/tests/pt/test_make_stat_input.py Show resolved Hide resolved
source/tests/pt/test_make_stat_input.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
deepmd/utils/argcheck.py (1)

2903-2909: Consider enhancing the documentation.

While the parameter implementation looks good, the documentation could be more descriptive about:

  • What exactly is being checked when elements are validated
  • The implications of enabling/disabling this feature
  • Any potential impact on performance or behavior
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ec779f and 24d1386.

📒 Files selected for processing (1)
  • deepmd/utils/argcheck.py (1 hunks)
🔇 Additional comments (2)
deepmd/utils/argcheck.py (2)

2896-2902: LGTM! Parameter for controlling minimum frames per element.

The min_frames_per_element_forstat parameter provides good control over the statistical calculations when using mixed types by ensuring sufficient data points per element.


2896-2909: Verify the usage of these new parameters.

Let's check how these parameters are used in the codebase:

✅ Verification successful

Parameters are properly implemented and used

Both parameters are correctly integrated into the codebase:

  • Used in statistical calculations and element validation logic in pt/utils/stat.py
  • Properly initialized in pt/train/training.py with consistent default values
  • Covered by test cases in test_make_stat_input.py
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find where these new parameters are used in the codebase

# Check for min_frames_per_element_forstat usage
echo "Checking min_frames_per_element_forstat usage:"
rg "min_frames_per_element_forstat"

# Check for enable_element_completion usage
echo "Checking enable_element_completion usage:"
rg "enable_element_completion"

Length of output: 3102

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
deepmd/pt/utils/stat.py (4)

38-58: Enhance docstring with parameter types and examples.

The docstring could be improved by:

  1. Adding type hints for parameters in the docstring
  2. Including an example usage section
    """Pack data for statistics.
       Element checking is only enabled with mixed_type.

    Args:
-    - datasets: A list of datasets to analyze.
-    - dataloaders: Corresponding dataloaders for the datasets.
-    - nbatches: Batch count for collecting stats.
-    - min_frames_per_element_forstat: Minimum frames required for statistics.
-    - enable_element_completion: Whether to perform missing element completion (default: True).
+    - datasets: list[Dataset]
+        A list of datasets to analyze.
+    - dataloaders: list[DataLoader]
+        Corresponding dataloaders for the datasets.
+    - nbatches: int
+        Batch count for collecting stats.
+    - min_frames_per_element_forstat: int, optional
+        Minimum frames required for statistics. Defaults to 10.
+    - enable_element_completion: bool, optional
+        Whether to perform missing element completion. Defaults to True.

    Returns
    -------
    list[dict]
        A list of dicts, each of which contains data from a system.

+    Example
+    -------
+    >>> stats = make_stat_input(datasets, dataloaders, 5, 
+    ...                        min_frames_per_element_forstat=10,
+    ...                        enable_element_completion=True)
    """

64-74: Improve logging structure and clarity.

The logging messages could be more structured and informative.

     if datasets[0].mixed_type:
         if enable_element_completion:
             log.info(
-                f"Element check enabled. "
-                f"Verifying if frames with elements meet the set of {min_frames_per_element_forstat}."
+                f"Element completion: enabled (minimum frames per element: {min_frames_per_element_forstat})"
             )
         else:
-            log.info(
-                "Element completion is disabled. Skipping missing element handling."
-            )
+            log.info("Element completion: disabled")

130-143: Add type hints to helper function.

The function lacks type hints which would improve code maintainability.

-    def finalize_stats(sys_stat):
+    def finalize_stats(sys_stat: dict[str, Union[None, np.float32, list[torch.Tensor]]]) -> None:
         """Finalize statistics by concatenating tensors."""

144-157: Consider memory optimization for large datasets.

The current implementation loads all tensors into memory. Consider processing in chunks for large datasets.

Consider implementing a chunked processing approach:

def process_in_chunks(dataloader, chunk_size=1000):
    sys_stat = {}
    for i in range(0, len(dataloader), chunk_size):
        chunk = itertools.islice(dataloader, i, i + chunk_size)
        process_chunk(chunk, sys_stat)
    return sys_stat
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24d1386 and 02f3f28.

📒 Files selected for processing (1)
  • deepmd/pt/utils/stat.py (1 hunks)
🔇 Additional comments (3)
deepmd/pt/utils/stat.py (3)

61-63: 🛠️ Refactor suggestion

Remove unused variable.

The variable global_element_counts is initialized but never used in the code.

 total_element_types = set()
-global_element_counts = {}
 collect_ele = defaultdict(int)

Likely invalid or redundant comment.


97-129: Optimize frame processing and add validation.

The function could be optimized and needs better validation:

  1. Add validation for frame data
  2. Consider batching frame processing for better performance

75-96: 🛠️ Refactor suggestion

Add error handling for unknown data types.

The function silently ignores unknown data types, which could hide potential issues.

                 elif isinstance(stat_data[dd], np.float32):
                     sys_stat[dd] = stat_data[dd]
                 else:
-                    pass
+                    log.warning(f"Unexpected data type {type(stat_data[dd])} for key {dd}")

Likely invalid or redundant comment.

deepmd/pt/utils/stat.py Show resolved Hide resolved
deepmd/pt/utils/stat.py Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (1)
source/tests/pt/test_make_stat_input.py (1)

27-28: Optimize dictionary key iteration.

Use direct dictionary key iteration instead of calling .keys().

-    for key in batch[0].keys():
-        data_list = [d[key] for d in batch]
+    for key in batch[0]:
+        data_list = [d[key] for d in batch]
🧰 Tools
🪛 Ruff (0.8.2)

27-27: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02f3f28 and b6a483a.

📒 Files selected for processing (1)
  • source/tests/pt/test_make_stat_input.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
source/tests/pt/test_make_stat_input.py

27-27: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

🔇 Additional comments (1)
source/tests/pt/test_make_stat_input.py (1)

72-74: LGTM!

The helper method is well-implemented with an appropriate threshold for counting non-zero elements.

source/tests/pt/test_make_stat_input.py Outdated Show resolved Hide resolved
source/tests/pt/test_make_stat_input.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (1)
source/tests/pt/test_make_stat_input.py (1)

31-31: Optimize dictionary key lookup.

Minor optimization opportunity in the key lookup.

Apply this diff to optimize the key lookup:

-    for key in batch[0].keys():
+    for key in batch[0]:
🧰 Tools
🪛 Ruff (0.8.2)

31-31: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6a483a and 050dbaf.

📒 Files selected for processing (1)
  • source/tests/pt/test_make_stat_input.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
source/tests/pt/test_make_stat_input.py

31-31: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

source/tests/pt/test_make_stat_input.py Outdated Show resolved Hide resolved
source/tests/pt/test_make_stat_input.py Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (2)
source/tests/pt/test_make_stat_input.py (2)

24-35: Add type hints and docstring to the collate function.

The function would benefit from type hints and documentation explaining its purpose and parameters.

-def collate_fn(batch):
+def collate_fn(batch: Union[dict, List[dict]]) -> dict:
+    """Collate a batch of data samples into a single batch for PyTorch DataLoader.
+    
+    Args:
+        batch: A single dict or list of dicts containing numpy arrays or scalar values
+        
+    Returns:
+        dict: Collated batch with torch tensors
+    """

Also, optimize the key lookup:

-    for key in batch[0].keys():
+    for key in batch[0]:
🧰 Tools
🪛 Ruff (0.8.2)

28-28: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)


75-76: Add type hints and docstring to helper method.

The helper method would benefit from type hints and documentation.

-    def count_non_zero_elements(self, tensor, threshold=1e-8):
+    def count_non_zero_elements(self, tensor: torch.Tensor, threshold: float = 1e-8) -> int:
+        """Count elements in tensor with absolute value greater than threshold.
+        
+        Args:
+            tensor: Input tensor
+            threshold: Minimum absolute value to consider non-zero
+            
+        Returns:
+            int: Number of elements with absolute value > threshold
+        """
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 050dbaf and 2f37dfe.

📒 Files selected for processing (1)
  • source/tests/pt/test_make_stat_input.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
source/tests/pt/test_make_stat_input.py

28-28: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (1)
source/tests/pt/test_make_stat_input.py (1)

25-36: Minor optimization for dict key lookup.

The code is functionally correct, but there's a small optimization opportunity.

-    for key in batch[0].keys():
+    for key in batch[0]:
🧰 Tools
🪛 Ruff (0.8.2)

29-29: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f37dfe and 47fe45b.

📒 Files selected for processing (1)
  • source/tests/pt/test_make_stat_input.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
source/tests/pt/test_make_stat_input.py

29-29: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (c-cpp)
🔇 Additional comments (2)
source/tests/pt/test_make_stat_input.py (2)

1-23: LGTM! Well-organized imports.

The imports are properly structured, following the standard practice of grouping imports by their source (standard library, third-party, and local modules).


76-78: LGTM! Well-implemented helper method.

The helper method correctly uses a threshold for floating-point comparisons.

source/tests/pt/test_make_stat_input.py Show resolved Hide resolved
source/tests/pt/test_make_stat_input.py Show resolved Hide resolved
source/tests/pt/test_make_stat_input.py Show resolved Hide resolved
source/tests/pt/test_make_stat_input.py Show resolved Hide resolved
source/tests/pt/test_make_stat_input.py Show resolved Hide resolved
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 92.53731% with 10 lines in your changes missing coverage. Please review.

Project coverage is 84.57%. Comparing base (dbdb9b9) to head (c05ffb1).
Report is 1 commits behind head on devel.

Files with missing lines Patch % Lines
deepmd/pt/utils/stat.py 92.45% 8 Missing ⚠️
deepmd/utils/data.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #4496      +/-   ##
==========================================
+ Coverage   84.55%   84.57%   +0.01%     
==========================================
  Files         677      677              
  Lines       63903    64007     +104     
  Branches     3488     3486       -2     
==========================================
+ Hits        54035    54132      +97     
- Misses       8743     8748       +5     
- Partials     1125     1127       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SumGuo-88
Copy link
Collaborator Author

SumGuo-88 commented Jan 8, 2025

Code efficiency test: Enabling element inspection (enable_element_completion = true, min_frames_per_element_forstat = 10)(about 117 mins) takes about three more minutes compared to disabling it (enable_element_completion = false) (about 114 mins) on the OC2M dataset with 4×V100 GPUs.

@SumGuo-88 SumGuo-88 requested a review from iProzd January 8, 2025 12:53
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
deepmd/pt/entrypoints/main.py (2)

389-389: Consider renaming the parameter for consistency.

The parameter name elem_check_stat doesn't match the CLI argument name skip-elementcheck. Additionally, their logic is inverted which could be confusing.

-def change_bias(..., elem_check_stat: bool = True):
+def change_bias(..., enable_element_completion: bool = True):

560-560: Fix inverted logic between function and CLI argument.

The function parameter defaults to True but is set from a CLI flag that defaults to False. This inversion makes the code harder to understand.

-            elem_check_stat=FLAGS.skip_elementcheck,
+            enable_element_completion=not FLAGS.skip_elementcheck,
deepmd/pt/utils/stat.py (4)

61-74: Remove unused variable.

The variable global_element_counts is initialized but never used.

 total_element_types = set()
-global_element_counts = {}
 collect_ele = defaultdict(int)

75-96: Add error handling for unknown data types.

The function silently passes on unknown data types, which could hide potential issues.

                 else:
-                    pass
+                    log.warning(f"Unexpected data type {type(stat_data[dd])} for key {dd}")

161-194: Add validation for element counts.

The element counting logic needs validation and could be simplified.

         if datasets[0].mixed_type and enable_element_completion:
+            if not isinstance(element_counts, dict):
+                log.warning(f"Invalid element counts for dataset {sys_index}")
+                continue
             for elem, data in element_counts.items():
+                if not isinstance(data, dict) or "indices" not in data or "frames" not in data:
+                    log.warning(f"Invalid data format for element {elem}")
+                    continue
                 indices = data["indices"]
                 count = data["frames"]

195-216: Improve error handling for missing elements.

The missing element handling could be improved with better error messages and validation.

     if datasets[0].mixed_type and enable_element_completion:
+        if not total_element_types:
+            log.warning("No elements found in any dataset")
+            return lst
         for elem, data in global_element_counts.items():
             indices_count = data["count"]
             if indices_count < min_frames_per_element_forstat:
                 log.warning(
-                    f"The number of frames in your datasets with element {elem} is {indices_count}, "
-                    f"which is less than the required {min_frames_per_element_forstat}"
+                    f"Insufficient frames for element {elem}: found {indices_count}, "
+                    f"required {min_frames_per_element_forstat}. This may affect model accuracy."
                 )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a30053f and 73a20b0.

📒 Files selected for processing (3)
  • deepmd/main.py (1 hunks)
  • deepmd/pt/entrypoints/main.py (3 hunks)
  • deepmd/pt/utils/stat.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Build wheels for cp310-manylinux_aarch64
  • GitHub Check: Build wheels for cp311-win_amd64
  • GitHub Check: Build wheels for cp311-macosx_x86_64
  • GitHub Check: Build wheels for cp311-manylinux_x86_64
  • GitHub Check: Test Python (6, 3.12)
  • GitHub Check: Test Python (6, 3.9)
  • GitHub Check: Test Python (5, 3.12)
  • GitHub Check: Test Python (5, 3.9)
  • GitHub Check: Test Python (4, 3.12)
  • GitHub Check: Test Python (4, 3.9)
  • GitHub Check: Test Python (3, 3.12)
  • GitHub Check: Test Python (3, 3.9)
  • GitHub Check: Test Python (2, 3.12)
  • GitHub Check: Test Python (2, 3.9)
  • GitHub Check: Test C++ (false)
  • GitHub Check: Test Python (1, 3.12)
  • GitHub Check: Test C++ (true)
  • GitHub Check: Test Python (1, 3.9)
  • GitHub Check: Build C library (2.18, libdeepmd_c.tar.gz)
  • GitHub Check: Analyze (c-cpp)
🔇 Additional comments (5)
deepmd/main.py (1)

740-744: LGTM!

The CLI argument is well-defined with a clear help message that explains its purpose.

deepmd/pt/utils/stat.py (4)

38-57: LGTM!

The function signature and docstring are well-documented with clear parameter descriptions.


133-146: LGTM!

The finalize_stats helper function is well-structured and handles all edge cases.


97-132: 🛠️ Refactor suggestion

Add validation for frame data.

The function should validate that the frame actually contains the missing element before processing.

                 if newele_counter <= min_frames_per_element_forstat:
                     frame_data = sys.__getitem__(frame)
+                    # Validate frame contains the missing element
+                    if "atype" not in frame_data:
+                        log.warning(f"Frame {frame} does not contain type information")
+                        continue
+                    frame_types = frame_data["atype"]
+                    if miss not in frame_types:
+                        log.warning(f"Frame {frame} does not contain element {miss}")
+                        continue

Likely invalid or redundant comment.


147-160: 🛠️ Refactor suggestion

Add input validation.

The initialization section needs validation for input parameters and data consistency.

+    if not datasets:
+        raise ValueError("No datasets provided")
+    if len(datasets) != len(dataloaders):
+        raise ValueError("Number of datasets does not match number of dataloaders")
+    if min_frames_per_element_forstat < 1:
+        raise ValueError("min_frames_per_element_forstat must be positive")
     total_element_types = set()
     collect_ele = defaultdict(int)

Likely invalid or redundant comment.

@SumGuo-88
Copy link
Collaborator Author

Adaptation for the change-bias feature has been added. Users can now adjust the minimum number of frames used for each element’s statistics by using the -mf or --min-frames option. Additionally, the --skip-elementcheck option has been introduced, allowing users to skip element checks even when errors occur during change-bias operations.

@@ -737,6 +737,18 @@ def main_parser() -> argparse.ArgumentParser:
default=None,
help="Model branch chosen for changing bias if multi-task model.",
)
parser_change_bias.add_argument(
"--skip-elementcheck",
action="store_false",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it store_true ?

@@ -555,6 +559,8 @@ def main(args: Optional[Union[list[str], argparse.Namespace]] = None) -> None:
numb_batch=FLAGS.numb_batch,
model_branch=FLAGS.model_branch,
output=FLAGS.output,
elem_check_stat=FLAGS.skip_elementcheck,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 'doing' elementcheck == 'skip' elementcheck ?

Comment on lines +2896 to +2909
Argument(
"min_frames_per_element_forstat",
int,
default=10,
optional=True,
doc="The minimum number of frames per element used for statistics when using the mixed type.",
),
Argument(
"enable_element_completion",
bool,
optional=True,
default=True,
doc="Whether to check elements when using the mixed type",
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc: doc_only_pt_supported + doc_xxx

@@ -40,6 +43,38 @@ def __getitem__(self, index):
b_data["natoms"] = self._natoms_vec
return b_data

def get_frame_index(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe get_frame_index_for_elements

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to make element_counts keys be element itself (e.g. H O)? It's not readable only seeing int keys in element_counts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Incomplete and risky bias statistics
2 participants