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

reduce the usage of try ... except KeyError: #347

Open
hbaniecki opened this issue Mar 21, 2025 · 0 comments
Open

reduce the usage of try ... except KeyError: #347

hbaniecki opened this issue Mar 21, 2025 · 0 comments
Labels
long term 📆 TODO long term maintenance 🔨 Code enhancements, tests and maintenance

Comments

@hbaniecki
Copy link
Collaborator

In places where you want to check if the key is present in a dictionary, e.g. in

try: # if coalition is not new
self.sampled_coalitions_dict[paired_coalition_tuple] += 1
except KeyError: # if coalition is new
self.sampled_coalitions_dict[paired_coalition_tuple] = 1
sampling_budget -= 1

try:
transformed_dict[interaction] += update_interaction
except KeyError:
transformed_dict[interaction] = update_interaction

but there might be more

@hbaniecki hbaniecki added maintenance 🔨 Code enhancements, tests and maintenance long term 📆 TODO long term labels Mar 21, 2025
@mmschlk mmschlk moved this to 💡Idea in shapiq development Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
long term 📆 TODO long term maintenance 🔨 Code enhancements, tests and maintenance
Projects
Status: 💡Idea
Development

No branches or pull requests

1 participant