-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add functions for tagged_data of multiple Tags/MultiTags #19
base: master
Are you sure you want to change the base?
Conversation
This pull request introduces 1 alert when merging 3449ccf into 6916644 - view on LGTM.com new alerts:
|
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.
Found a few issues that prevented deep testing so I'm not sure if the rest works. It looks good, but I'd want to test again when the issues are fixed.
if ref not in mt.references and not isinstance(ref, int): | ||
raise ValueError("This DataArray is not referenced.") | ||
if isinstance(ref, int) and ref > len(mt.references): | ||
raise nix.exceptions.OutOfBounds("The index given is out of bound.") |
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.
If you reverse these conditions, you wont need the not isinstance(ref, int)
in the first one.
Another reason it's better to test for the type first is because the search for ref
in mt.references
will do a full scan through the references list, which is a more costly operation than a type check.
start = np.array(start, dtype=int) | ||
end = np.array(end, dtype=int) |
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.
Positions and extents aren't integers, they're in the units of the dimension of the referenced arrays. There's no need to specify a dtype
here anyway, just let the array()
function figure it out.
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.
Ah yes, sorry, I should convert them to indices first. Here I assume they are indices, forgot to go so.
nixworks/multi_tag.py
Outdated
return True | ||
|
||
|
||
def _sorting(starts, ends): # li is the start values |
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.
# li is the start values
???
self.p = mkdtemp() | ||
self.testfilename = os.path.join(self.p, "test.nix") | ||
self.file = nix.File.open(self.testfilename, nix.FileMode.Overwrite) | ||
self.block = self.file.create_block("test_block", "abc") | ||
self.arr1d = np.arange(1000) | ||
self.ref1d = self.block.create_data_array("test1d", "test", data=self.arr1d) | ||
self.ref1d.append_set_dimension() | ||
self.arr3d = np.arange(1000).reshape((10, 10, 10)) | ||
self.ref3d = self.block.create_data_array("test3d", "test", data=self.arr3d) | ||
self.ref3d.append_set_dimension() | ||
self.ref3d.append_set_dimension() |
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.
Tagging set dimensions isn't very interesting and simplifies a lot of the data retrieval. A SampledDimension would be more useful for getting a sense of the whole problem. This is also why the bug with the integer truncation/casting in the _populate_start_end()
function wasn't caught.
Also, make sure to add |
This pull request introduces 1 alert when merging 31bcee5 into 6916644 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging a7db896 into 6916644 - view on LGTM.com new alerts:
|
This pull request introduces 2 alerts when merging 7d68bd8 into 6916644 - view on LGTM.com new alerts:
|
This pull request introduces 2 alerts when merging 27a9428 into c063574 - view on LGTM.com new alerts:
|
This pull request introduces 2 alerts when merging 9d9c012 into c063574 - view on LGTM.com new alerts:
|
nixpy issue #411
There are 2 functions for public use: union and intersection. They return the non-overlapping union and the overlapping area of the tagged_data of multiple tags.
Tests are added.
I follow the return values of Tags and MultiTags by commit 6487b8f6b30282f9f60cda2f7df54b24965f463f in NIXPy, such that the stop value of position+extent is included in the return value. Example: position=(0,) and extent=(12,) the tagged data will return 13 values.