Skip to content

updated with max_ent - #81

Open
Henry-Plante wants to merge 7 commits into
MUEXLY:mainfrom
Henry-Plante:main
Open

Henry-Plante wants to merge 7 commits into
MUEXLY:mainfrom
Henry-Plante:main

Conversation

@Henry-Plante

Copy link
Copy Markdown

No description provided.

Comment thread main.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be a test in test_lib.py, not a whole new file

Comment thread tce/calculator.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks mostly good. but it looks like you're using an old version of tce-lib here.

After commit 7fb3ac3, we don't use scipy.spatial.KDTree anymore for the neighbor finding. Also, you re-implemented TCECalculator.get_batched_feature_vectors - this was added in the same commit.

Comment thread tce/calculator.py Outdated
from opt_einsum import contract
from multiset import Multiset

# new import for optimized sorting:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The import order should look like:

  • built-ins (standard library modules like typing)
  • third party modules (like numpy, sparse)
  • local modules (like .training)

Comment thread tce/calculator.py Outdated
LATIN_ALPHABET = "ijklmnopqrstuvwxyz"

#max_ent funct for optimized matrix sorting
def maximum_entropy_subset_up_to_size_k(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should probably be a "private" method

i put private in quotes because python doesn't actually have these, but there's a standardized way we can denote it:

  • rename it with an underscore (foo -> _foo)

we also use pdoc to generate documentation and we shouldn't have private functions in the documentation. you can add @private in the doc-string to make sure pdoc doesn't catch it:

https://pdoc.dev/docs/pdoc.html#control-what-is-documented

Comment thread tce/calculator.py Outdated
topological_tensors = self.topological_tensors.get(topology_key)

if topological_tensors is None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

old tce-lib version, see the git diff where this error guard doesn't exist

Comment thread tce/calculator.py Outdated
return obj

# err handling and center controlling
def get_batched_feature_vectors(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't exist, see comment on file

Comment thread tce/calculator.py
Comment thread .vscode/settings.json Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

uncommit this file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

by this, i mean that this file should not be committed at all. you'll need to delete it from the git tree

Comment thread tce/calculator.py Outdated

from dataclasses import dataclass, field
from typing import Optional, Union
from typing import Optional, Union, Generator, Sequence # updated import order

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should not have comments in the lines. no need for the comment here in the imports

Comment thread tce/calculator.py Outdated
import numpy as np
from numpy.typing import NDArray
import sparse
from scipy.spatial import KDTree

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

new version shouldn't depend on scipy at all, so get rid of this import

Comment thread tce/calculator.py Outdated

topological_tensors = self.get_topological_tensors(atoms)

#symbols = np.array(atoms.get_chemical_symbols())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove this line

Comment thread tce/calculator.py


@cite(paper_link=ORIGINAL_PAPER)
def get_feature_vector(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you're missing the @cite decorator here, see the git diff

Comment thread tce/calculator.py
r"""
Finds and selects subsets that maximize the feature entropy.

Parameters:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

docstring here is wrong, your annotation is missing atoms_list parameter, and annotates the self parameter. no need to annotate the self parameter

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

docstring is still wrong; the atoms_list parameter is not a "matrix of sequence vectors"

Comment thread test_lib.py Outdated
np.testing.assert_array_equal(a1.numbers, a2.numbers)
np.testing.assert_allclose(a1.positions, a2.positions)

print("Test passed: Method 1 and Method 2 yield identical results!")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need for the print here, the norm for pytest is to print out info when tests fail

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants