-
-
Notifications
You must be signed in to change notification settings - Fork 132
add full function to simplify COO creation #150
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
Codecov Report
@@ Coverage Diff @@
## master #150 +/- ##
==========================================
+ Coverage 95.77% 95.78% +0.01%
==========================================
Files 10 10
Lines 1183 1187 +4
==========================================
+ Hits 1133 1137 +4
Misses 50 50
Continue to review full report at Codecov.
|
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.
Hello, @ahwillia! A big thanks for adding to the project. Every contribution is welcome. As for your questions:
- You can accept non-array values for coords, the
COO
constructor fixes those for you. SeeLine 227 in 3a53e87
self.coords = np.asarray(coords) - I would recommend mirroring the signature of
np.full
rather than adding**kwargs
, and then documenting those keywords as usual. If you prefer to keep**kwargs
, though, just document it like this:
kwargs : dict, optional
Additional arguments to pass to ``np.full``.
- Your PR is fairly complete, but it's missing one thing. In this file, you need to add
full
in its proper place alphabetically: https://github.com/pydata/sparse/blob/a95b372df35a4f771a5b045c487079e64477d38c/docs/generated/sparse.rst
sparse/tests/test_coo.py
Outdated
|
||
a = sparse.full(coords, 1) | ||
e = np.diag(np.ones(5, dtype=int)) | ||
assert_eq(e, a, compare_dtype=True) |
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.
compare_dtype
is on by default, no need to add it here.
sparse/tests/test_coo.py
Outdated
|
||
a = sparse.full(coords, 1.0) | ||
e = np.diag(np.ones(5)) | ||
assert_eq(e, a, compare_dtype=True) |
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.
See comment to above.
I wonder if it would make sense to have the COO constructor do this automatically x = COO(coords=..., data=1) To my knowledge this doesn't conflict with any other potential input. |
Yes, we can. The question is whether we should add this to the constuctor, which is already quite bloated (both in terms of using and coding). |
I agree that it's somewhat bloated, however to me this doesn't seem to
increase that bloat substantially.
…On Sat, May 5, 2018 at 10:00 AM, Hameer Abbasi ***@***.***> wrote:
Yes, we can. The question is whether we should add this to the constuctor,
which is already quite bloated (both in terms of using and coding).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#150 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AASszBBFqtvk8Bw-uI4JwZjCv9EsxOmnks5tvbBngaJpZM4TzdB0>
.
|
Fair enough. We can just replace |
Thanks for the feedback.
I am actually passing As someone who just started playing around with the package I actually find the COO constructor a bit confusing. I would be in favor of keeping I don't mind also adding this to the Would it make sense to hold off on this PR and open an issue/discussion on the |
Sure. I'm +0.5 on changing constructor behaviour. @ahwillia would you mind opening that issue? |
Closing this in favor of #152 |
This package may end up being very important to me, so I wanted to dip my toes in and try adding a simple extension in case I want to add something more substantial later.
The basic idea is to make array creation easier when all the data values are the same (I think this is incredibly common, e.g. if you are representing sparse graph structure)
A few things I wasn't sure on...
**kwargs
coords
? In particular should I add something to the effect ofcoords = np.asarray(coords)
at the top of my functionHope that this is welcome and within scope. Thanks!