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

Object inconsistency #1843

Open
ubuntujule opened this issue Jun 25, 2024 · 3 comments
Open

Object inconsistency #1843

ubuntujule opened this issue Jun 25, 2024 · 3 comments

Comments

@ubuntujule
Copy link

after initializing a holiday.[COUNTRY] object and also with holidays.country_holidays('COUNTRY_STRING') the object is a holidays.country_holidays instance object - for example: "<class 'holidays.countries.germany.DE'>"

__repr__ is also "holidays.country_holidays('[COUNTRY')" after initializing but after using a method takes an parameter with a Date (e.g. like Holiday.Base.get_list() method),
the __repr__ is a dict with all relevant holidays (which is better than get the class in __repr__ because the class Object we also will get with a type(object) call - in my opinion).

>>>
>>> h = holidays.country_holidays('US')
>>> h
holidays.country_holidays('US')
>>> h.get_list(da)
[]
>>> h
{datetime.date(2024, 1, 1): "New Year's Day", datetime.date(2024, 5, 27): 'Memorial Day', datetime.date(2024, 6, 19): 'Juneteenth National Independence Day', datetime.date(2024, 7, 4): 'Independence Day', datetime.date(2024, 9, 2): 'Labor Day', datetime.date(2024, 11, 11): 'Veterans Day', datetime.date(2024, 11, 28): 'Thanksgiving', datetime.date(2024, 12, 25): 'Christmas Day', datetime.date(2024, 1, 15): 'Martin Luther King Jr. Day', datetime.date(2024, 2, 19): "Washington's Birthday", datetime.date(2024, 10, 14): 'Columbus Day'}
>>>
@arkid15r
Copy link
Collaborator

It seems this behavior is intentional. Could you add the expected result as I'm having hard time understanding what's your suggestion for the fix.

I don't expect this to be changed in v0 however I'd be happy to improve this for the next version -- v1 (currently WIP).

Thank you!

@ubuntujule
Copy link
Author

ubuntujule commented Jul 10, 2024

I would expect that on first print of the object we also get a dict of all holidays instead of the class.

current output:

>>>
>>> h = holidays.country_holidays('US')
>>> h
holidays.country_holidays('US')
>>> h.get_list(da)
[]
>>> h
{datetime.date(2024, 1, 1): "New Year's Day", datetime.date(2024, 5, 27): 'Memorial Day', datetime.date(2024, 6, 19): 'Juneteenth National Independence Day', datetime.date(2024, 7, 4): 'Independence Day', datetime.date(2024, 9, 2): 'Labor Day', datetime.date(2024, 11, 11): 'Veterans Day', datetime.date(2024, 11, 28): 'Thanksgiving', datetime.date(2024, 12, 25): 'Christmas Day', datetime.date(2024, 1, 15): 'Martin Luther King Jr. Day', datetime.date(2024, 2, 19): "Washington's Birthday", datetime.date(2024, 10, 14): 'Columbus Day'}
>>>

modified output, I would expect:

>>>
>>> h = holidays.country_holidays('US')
>>> h
{datetime.date(2024, 1, 1): "New Year's Day", datetime.date(2024, 5, 27): 'Memorial Day', datetime.date(2024, 6, 19): 'Juneteenth National Independence Day', datetime.date(2024, 7, 4): 'Independence Day', datetime.date(2024, 9, 2): 'Labor Day', datetime.date(2024, 11, 11): 'Veterans Day', datetime.date(2024, 11, 28): 'Thanksgiving', datetime.date(2024, 12, 25): 'Christmas Day', datetime.date(2024, 1, 15): 'Martin Luther King Jr. Day', datetime.date(2024, 2, 19): "Washington's Birthday", datetime.date(2024, 10, 14): 'Columbus Day'}
>>> h.get_list(da)
[]
>>> h
{datetime.date(2024, 1, 1): "New Year's Day", datetime.date(2024, 5, 27): 'Memorial Day', datetime.date(2024, 6, 19): 'Juneteenth National Independence Day', datetime.date(2024, 7, 4): 'Independence Day', datetime.date(2024, 9, 2): 'Labor Day', datetime.date(2024, 11, 11): 'Veterans Day', datetime.date(2024, 11, 28): 'Thanksgiving', datetime.date(2024, 12, 25): 'Christmas Day', datetime.date(2024, 1, 15): 'Martin Luther King Jr. Day', datetime.date(2024, 2, 19): "Washington's Birthday", datetime.date(2024, 10, 14): 'Columbus Day'}
>>>

@arkid15r
Copy link
Collaborator

A brand new holidays.country_holidays('US') object is empty be default. You can specify years you want to be populated upon creation using years parameter -- holidays.country_holidays('US', years=2024). Please see the docs for more examples.

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

No branches or pull requests

2 participants