Add backwards compatible collect function - #59
Conversation
…r of boutdata.collect().
TomNicholas
left a comment
There was a problem hiding this comment.
This is great, thanks @rdoyle45 .
Main thing it needs is tests to check the indexing behaving as expected. Then this can also be tested against the actual old collect function.
|
No, isel accepts a dictionary where the values are either an int, a list of
ints, or a slice. The only difference we have to account for is that isel
treats a list of indexes as a list individual locations you want to select,
so [5,10] would give you the 5th and 10th element, not elements 5 through
10 as the old collect does.
…On Mon, 28 Oct 2019, 13:36 Rhys Doyle, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In xbout/load.py
<#59 (comment)>:
> + selection = {}
+
+ for i in range(len(dims)):
+
+ if indexers[i] != None:
+
+ if isinstance(indexers[i], int):
+ selection[dims[i]] = [indexers[i]]
+ else:
+ selection[dims[i]] = indexers[i]
Very true, I will simplify now.
For specific index extraction I think iselneeds to given a list object so isinstance(ind,
int) would need to be checked too?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#59?email_source=notifications&email_token=AISNPI463U2D7YWTJDCPYITQQ3TGPA5CNFSM4JFZVJV2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCJMWVXI#discussion_r339564916>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AISNPI7GNFTW364BRCNMACDQQ3TGPANCNFSM4JFZVJVQ>
.
|
|
Apologies I meant say within a dictionary. When I was testing Am I missing something or is this correct? |
|
Hmm I'm actually not sure, I was testing just now by doing `isel(t=5)`, but
perhaps I should have been doing `isel(dict('t' : 5))`.
What I suggest is that you practice test-driven-development here. Write out
small tests for each case that should work, including handling `None` and
so on. Then change the collect logic until the tests all pass. That process
will be less likely to leave errors than trying to guess how `isel` behaves
and hoping you've covered each possibility.
…On Mon, 28 Oct 2019, 13:55 Rhys Doyle, ***@***.***> wrote:
Apologies I meant say within a dictionary.
When I was testing isel with for example dict = {'x' : 3} ds.isel(dict)
would remove the x dimension entirely. When I use dict = {'x' : [3]} a
single x index is extracted.
Am I missing something or is this correct?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#59?email_source=notifications&email_token=AISNPIZ7VDHBWPJS5KLIZZTQQ3VMHA5CNFSM4JFZVJV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECM6OVI#issuecomment-546957141>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AISNPI43JDXRU2XSI7BYOGTQQ3VMHANCNFSM4JFZVJVQ>
.
|
|
Thanks Tom, will do. I'll check that now.
|
…ated and tests added (tests will fail if xguards and yguards parameters change, issue being looked at in #61)
|
Will wait until #55 is merged |
Codecov Report
@@ Coverage Diff @@
## master #59 +/- ##
===========================================
- Coverage 68.69% 44.74% -23.96%
===========================================
Files 7 8 +1
Lines 444 789 +345
Branches 95 152 +57
===========================================
+ Hits 305 353 +48
- Misses 85 380 +295
- Partials 54 56 +2
Continue to review full report at Codecov.
|
|
I have added tests to check each dimension and index type. I have kept the list indexing as exclusive when using This may change depending on the results of boutproject/BOUT-dev#1861 , and therefore we should wait to merge. However all tests should pass at present and any change in #1861 should not make the tests fail. What do you think @johnomotani? I think the tests are quite robust now. |
johnomotani
left a comment
There was a problem hiding this comment.
Looks good to me. Probably worth holding off on merging for a little while to see if there's a resolution to the discussion in boutproject/BOUT-dev#1861.
Agreed |
|
Following discussion on boutproject/BOUT-dev#1862, I think we can remove support and tests for the 3-element list form. |
Removed. I think this is good to go? @TomNicholas @johnomotani |
Issue has been resolved - indexing now tested against old collect.
Add backwards compatible collect function
This pull request adds a new function, collect(), to xBOUT which aims to replicate the behaviour of https://github.com/boutproject/boutdata/blob/master/boutdata/collect.py.
Feature suggested in #9