-
Notifications
You must be signed in to change notification settings - Fork 26
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
Added support to download example datasets #24
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #24 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 23 24 +1
Lines 1462 1471 +9
=========================================
+ Hits 1462 1471 +9 ☔ View full report in Codecov by Sentry. |
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!
concepts/examples.py
Outdated
|
||
|
||
# inspired by https://github.com/mwaskom/seaborn/blob/master/seaborn/utils.py#L524 | ||
def load_dataset(name: str, data_src: typing.Optional[str] = DATASET_SOURCE, |
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.
nit: How about keyword-only arguments for eveything except name
(and maybe that one even positional-only)?
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.
Good idea. I implemented this in the latest commits.
concepts/examples.py
Outdated
|
||
# TODO: implement caching here? | ||
|
||
return Context.fromstring(urlopen(url).read().decode(encoding), 'cxt') |
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.
Maybe we should use a context-manager for urlopen()
?
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.
Definitely. Done.
tests/test_examples.py
Outdated
@@ -0,0 +1,10 @@ | |||
import pytest |
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.
unused import
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.
removed.
|
||
|
||
def test_load_dataset(): | ||
context = concepts.load_dataset('livingbeings_en') |
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.
We should probbaly not depend on internet connectivity in the test.
How about having a mocked test and another one doing the actual thing that would be opt-in with a flag?
Something mildy related here: https://github.com/xflr6/graphviz/blob/e5578d39009469df2b7c6743458970643e228226/tests/conftest.py#L5
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.
I agree but I did not manage to implement this. The examples I found are mainly targeting unittest
and not pytest
(or pytest
with the requests
module).
Thanks for the PR.
Of course :) In recent times, I did not have much time for my open source projects but it would still be nice to make at least some small improvements. |
Dear Sebastian,
Inspired by other libraries (e.g., Seaborn and scikit-learn) I have added support to download exemplary contexts from the repository https://github.com/fcatools/contexts. For more context, please have a look at this post on the FCA mailing list.
We can discuss details on how to properly handle, curate and implement this but I hope you like the idea. I'd happily make you (co)owner of the conexts repo or https://github.com/orgs/fcatools/ such that you have control over what can be loaded.