-
Notifications
You must be signed in to change notification settings - Fork 874
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
Convert kpts
in Kpoints
to Sequence[tuple]
and set it as property
#3758
Convert kpts
in Kpoints
to Sequence[tuple]
and set it as property
#3758
Conversation
Warning Rate Limit Exceeded@DanielYang59 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 39 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe updates across various files in the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
I just opened this early PR @janosh. Seems a lot of work and I'm quite concerned this might break many others (in typing, I don't expect much functional change thought, except for mutability). Would you suggest |
I would prefer typing as int since float will still work and only cause a type error |
I agree with you on this, we should not cater too much to edge cases (0-decimal Shouldn't we add another custom type to Kpoint = tuple[int, int, int] Maybe do the same to coordinates in the near future? Coordinate = tuple[float, float, float] Meanwhile, maybe we should consider using a more general |
good idea!
yes, i forgot to add could you move the pymatgen/pymatgen/core/trajectory.py Line 30 in 37d1066
that's a good point. let's do it your way |
Yes sure.
Great. I would try implement this. Thanks for the feedback. Meanwhile, I don't know what is the best place to put the type |
Please review this if you have time @janosh :) I ended up adding type alias as
Any suggestion would be appreciated :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 13
Out of diff range and nitpick comments (4)
pymatgen/io/vasp/inputs.py (1)
Line range hint
1083-1099
: Consider adding type hints for the constructor parameters of theKpoints
class to improve code readability and maintainability.- def __init__( + def __init__(self, comment: str = "Default gamma", num_kpts: int = 0, style: KpointsSupportedModes = supported_modes.Gamma, kpts: Sequence[Kpoint] = ((1, 1, 1),), kpts_shift: Vector3D = (0, 0, 0), kpts_weights: list[float] | None = None, coord_type: Literal["Reciprocal", "Cartesian"] | None = None, labels: list[str] | None = None, tet_number: int = 0, tet_weight: float = 0, tet_connections: list[tuple] | None = None, ) -> None:pymatgen/io/vasp/sets.py (3)
Line range hint
235-235
: Add type hints to the class definition for better clarity and consistency with modern Python practices.- class DictSet(VaspInputSet): + class DictSet(VaspInputSet):
Line range hint
297-297
: Add type hints to the class definition for better clarity and consistency with modern Python practices.- class MITRelaxSet(DictSet): + class MITRelaxSet(DictSet):
Line range hint
315-315
: Add type hints to the class definition for better clarity and consistency with modern Python practices.- class MPRelaxSet(DictSet): + class MPRelaxSet(DictSet):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @DanielYang59, this looks good! just 2 minor comments 👍
kpts
in Kpoints
to tuple
and set it as property
kpts
in Kpoints
to Sequence[tuple]
and set it as property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great stuff as usual, thanks @DanielYang59! 👍
you're writing excellent tests 🧪
Thanks for reviewing and saying that! Appreciate it. |
@janosh Also worth noting it appears I was always wondering, does GitHub provide some dedicated container for CI tests (like codespace for CI)? As I notice environment preparation time is almost as much as actual test running time, it would be good to avoid building a new test env every time when there is no dependency change? |
are you referring to this error? E _tkinter.TclError: Can't find a usable tk.tcl in the following directories: That also used to happen with
The |
Yes I did notice this error multiple times within this PR, and sometimes the following:
for example here. I would let you know if I notice any others. The reason seems to be: in cases where
For some reason
That sounds interesting and worth some experiments on it. I might give it a try in the near future and let you know how everything goes :) Thanks for the input! |
you're right, i did see that one as well. are you sure this is a |
I'm not 100% sure. But as we could see from the log here inside the "install pymatgen and dependencies" section:
I would assume it's likely a |
FYI that this is a slight breaking change re: kpts no longer being a list but a tuple, although you likely are aware of this due to the change in the test suite. Edit: nvm, I see the comment here 6a06f3c#r140944147 |
Hi @Andrew-S-Rosen, yes we're fully aware it might be breaking to change But frankly I'm not quite sure if there is any unexpected side effect. Ideally things should only rely on the values of |
I don't think there will be too many practical side effects. I just noticed it failing my CI runs because I was checking for exact matches on |
Yes the original unit tests were doing the same and we have to change the types too. Hopefully there would not be many operations that replies on |
Summary
As discussed in 6a06f3c#r140944147.
kpts
inKpoints
toSequence[tuple[float, float, float]]
, and related type fixeskpts
asproperty
and add itssetter
, also add unit tests for this propertyutil.typing