-
Notifications
You must be signed in to change notification settings - Fork 267
Make netcdftime.datetime immutable and hashable. Fixes #255. #275
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
Conversation
Awesome! I'm glad you're able to work on this. The main complication is that |
assert hash(d1) != hash(d3) | ||
|
||
# check datetime immutability | ||
try: |
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.
The cleaner way to write this is:
with self.assertRaises(AttributeError):
d1.year = 1999
The immutability hack before was to avoid doing a lot repetitive properties, but I agree doing properties is cleaner and more intuitive. I updated the code to use that approach. Also, the hash function is now coded to use the hash from a |
The last remaining wrinkle would be hashing dates that can't be represented with Finally, this would be good time to bump the version in |
Sounds reasonable. I implemented the hashing as you suggested for dates that can't be represented with datetime. There is a unit test for that now too. I bumped the version up one minor number from 1.1 to 1.2. |
Looks good to go to me! 👍 |
Great! Let me know of anything else that needs to be done to merge. |
It's up to @jswhit now. |
Make netcdftime.datetime immutable and hashable. Fixes #255.
I went ahead and put together a pull request for the change approved in #255. The ticket approves making netcdftime.datetime immutable so it can be used as a dictionary key. This is my first contribution, so let me of any areas for improvement.
Best,
Daniel