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

change test_ucc line 246 tuple to int #114

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

change test_ucc line 246 tuple to int #114

wants to merge 11 commits into from

Conversation

TL231
Copy link
Contributor

@TL231 TL231 commented Oct 4, 2024

The class attributes of the Molecule class does not enforce types, run_pyscf also overrides the attributes, so the tuple is accepted without issues.
Shouldn't pass the ucc_ansatz due to typing issues though.
Regarding type enforcement, see link.
tl;dr is that enforcing type on class attributes during init is not recommended, if type enforcement is desired, we can follow the example in one of the answers.

Copy link

codecov bot commented Oct 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (16ee5b8) to head (92b9d6b).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #114   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines          622       622           
=========================================
  Hits           622       622           
Flag Coverage Δ
unittests 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@damarkian damarkian requested a review from chmwzc November 5, 2024 04:40
@chmwzc
Copy link
Contributor

chmwzc commented Dec 3, 2024

Any other changes that you want to make? If not, looks good to me, you can un-draft it and I'll merge it 👍

@TL231
Copy link
Contributor Author

TL231 commented Dec 3, 2024

There's another way to enforce class attribute type using the attr package link.
AFAIK, it should not affect anything. I'll try to implement it by this week, but if it fails, I'll undraft this to be merged.

@TL231
Copy link
Contributor Author

TL231 commented Dec 6, 2024

Seems to be working, the remaining errors are from the #119.

To note, although it is not listed, the class still accepts variables in the order they are listed in the class. Most of the variables are init as None without typing, and adding a type check is as simple as adding validator=attr.validators.instance_of(type) in attr.ib.

@chmwzc please help do a quick scan of the class and add appropriate validators if needed, do note that the validators will check the default and return an error if there's type mismatch. Leave out the validators if there's multiple acceptable typing.
_process_xyz_file has been subsume under attrs_post_init which automatically runs after init.

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