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

Add functions for tagged_data of multiple Tags/MultiTags #19

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

hkchekc
Copy link
Member

@hkchekc hkchekc commented Mar 26, 2020

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.

@hkchekc
Copy link
Member Author

hkchekc commented Mar 26, 2020

@achilleas-k @jgrewe

@lgtm-com
Copy link

lgtm-com bot commented Mar 30, 2020

This pull request introduces 1 alert when merging 3449ccf into 6916644 - view on LGTM.com

new alerts:

  • 1 for Module is imported with 'import' and 'import from'

Copy link
Member

@achilleas-k achilleas-k left a 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.

Comment on lines +11 to +15
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.")
Copy link
Member

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.

Comment on lines +32 to +34
start = np.array(start, dtype=int)
end = np.array(end, dtype=int)
Copy link
Member

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.

Copy link
Member Author

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.

return True


def _sorting(starts, ends): # li is the start values
Copy link
Member

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 ???

Comment on lines +14 to +24
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()
Copy link
Member

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.

@achilleas-k
Copy link
Member

Also, make sure to add from . import multi_tag in the top-level __init__.py to expose the module.

@lgtm-com
Copy link

lgtm-com bot commented Mar 30, 2020

This pull request introduces 1 alert when merging 31bcee5 into 6916644 - view on LGTM.com

new alerts:

  • 1 for Module is imported with 'import' and 'import from'

@lgtm-com
Copy link

lgtm-com bot commented Apr 8, 2020

This pull request introduces 1 alert when merging a7db896 into 6916644 - view on LGTM.com

new alerts:

  • 1 for Module is imported with 'import' and 'import from'

@lgtm-com
Copy link

lgtm-com bot commented Apr 8, 2020

This pull request introduces 2 alerts when merging 7d68bd8 into 6916644 - view on LGTM.com

new alerts:

  • 1 for Unused local variable
  • 1 for Module is imported with 'import' and 'import from'

@lgtm-com
Copy link

lgtm-com bot commented May 1, 2020

This pull request introduces 2 alerts when merging 27a9428 into c063574 - view on LGTM.com

new alerts:

  • 1 for Unused local variable
  • 1 for Module is imported with 'import' and 'import from'

@lgtm-com
Copy link

lgtm-com bot commented May 3, 2020

This pull request introduces 2 alerts when merging 9d9c012 into c063574 - view on LGTM.com

new alerts:

  • 1 for Unused local variable
  • 1 for Module is imported with 'import' and 'import from'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants