-
Notifications
You must be signed in to change notification settings - Fork 4
Implement readers for compressed lists #68
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
11c4a01
Read compressed integer lists
jkanche 9a4ee89
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ee482be
editable builds
jkanche a69cebb
bring actions upto date
jkanche 959dad1
remove prints, update test
jkanche 915b6f0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5978c52
tests for compressed lists
jkanche 18e4458
Merge branch 'compressed-lists' of https://github.com/biocpy/rds2py i…
jkanche be5065c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 23f3abb
update changelog
jkanche 27e1e4c
Merge branch 'compressed-lists' of https://github.com/biocpy/rds2py i…
jkanche b2e0dc0
Merge remote-tracking branch 'origin/master' into compressed-lists
jkanche 838c37f
python 3.9 EOL
jkanche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,206 @@ | ||
| """Functions and classes for parsing Compressed List data structures.""" | ||
|
|
||
| import numpy as np | ||
|
|
||
| from .generics import _dispatcher | ||
| from .rdsutils import get_class | ||
|
|
||
| __author__ = "jkanche" | ||
| __copyright__ = "jkanche" | ||
| __license__ = "MIT" | ||
|
|
||
|
|
||
| def read_partitioning_by_end(robject: dict, **kwargs): | ||
| """Read an partioning by end object. | ||
|
|
||
| Args: | ||
| robject: | ||
| Dictionary containing parsed partioning by end object. | ||
|
|
||
| **kwargs: | ||
| Additional arguments. | ||
|
|
||
| Returns: | ||
| A vector containing the partitions. | ||
| """ | ||
| _cls = get_class(robject) | ||
|
|
||
| if _cls not in ["PartitioningByEnd"]: | ||
| raise RuntimeError(f"`robject` does not contain not a `PartitioningByEnd` object, contains `{_cls}`.") | ||
|
|
||
| ends = _dispatcher(robject["attributes"]["end"], **kwargs) | ||
|
|
||
| from compressed_lists import Partitioning | ||
|
|
||
| return Partitioning(ends=np.asarray(ends)) | ||
|
|
||
|
|
||
| def _get_compressed_common_attrs(robject, **kwargs): | ||
| if "unlistData" not in robject["attributes"]: | ||
| raise ValueError("Object does not contain unlistData, is it really a `CompressedList`?") | ||
| unlist_data = _dispatcher(robject["attributes"]["unlistData"], **kwargs) | ||
|
|
||
| element_metadata = None | ||
| if "elementMetadata" in robject["attributes"]: | ||
| element_metadata = _dispatcher(robject["attributes"]["elementMetadata"], **kwargs) | ||
|
|
||
| metadata = None | ||
| if "metadata" in robject["attributes"]: | ||
| metadata = _dispatcher(robject["attributes"]["metadata"], **kwargs) | ||
|
|
||
| partition = None | ||
| if "partitioning" in robject["attributes"]: | ||
| partition = _dispatcher(robject["attributes"]["partitioning"], **kwargs) | ||
|
|
||
| return unlist_data, element_metadata, metadata, partition | ||
|
|
||
|
|
||
| def read_compressed_integer_list(robject: dict, **kwargs): | ||
| """Read an R compressed integer list. | ||
|
|
||
| Args: | ||
| robject: | ||
| Dictionary containing parsed compressed list. | ||
|
|
||
| **kwargs: | ||
| Additional arguments. | ||
|
|
||
| Returns: | ||
| A `CompressedList` from the 'compressed_lists' package. | ||
| """ | ||
| _cls = get_class(robject) | ||
|
|
||
| if _cls not in ["CompressedIntegerList"]: | ||
| raise RuntimeError(f"`robject` does not contain not a compressed integer list object, contains `{_cls}`.") | ||
|
|
||
| unlist_data, element_metadata, metadata, partition = _get_compressed_common_attrs(robject=robject, **kwargs) | ||
|
|
||
| from compressed_lists import CompressedIntegerList | ||
|
|
||
| return CompressedIntegerList( | ||
| unlist_data=unlist_data, partitioning=partition, element_metadata=element_metadata, metadata=metadata | ||
| ) | ||
|
|
||
|
|
||
| def read_compressed_string_list(robject: dict, **kwargs): | ||
| """Read an R compressed string/character list. | ||
|
|
||
| Args: | ||
| robject: | ||
| Dictionary containing parsed compressed list. | ||
|
|
||
| **kwargs: | ||
| Additional arguments. | ||
|
|
||
| Returns: | ||
| A `CompressedList` from the 'compressed_lists' package. | ||
| """ | ||
| _cls = get_class(robject) | ||
|
|
||
| if _cls not in ["CompressedCharacterList"]: | ||
| raise RuntimeError(f"`robject` does not contain not a compressed string list object, contains `{_cls}`.") | ||
|
|
||
| unlist_data, element_metadata, metadata, partition = _get_compressed_common_attrs(robject=robject, **kwargs) | ||
|
|
||
| from compressed_lists import CompressedCharacterList | ||
|
|
||
| return CompressedCharacterList( | ||
| unlist_data=unlist_data, partitioning=partition, element_metadata=element_metadata, metadata=metadata | ||
| ) | ||
|
|
||
|
|
||
| def read_compressed_character_list(robject: dict, **kwargs): | ||
| """Read an R compressed string/character list. | ||
|
|
||
| Args: | ||
| robject: | ||
| Dictionary containing parsed compressed string list. | ||
|
|
||
| **kwargs: | ||
| Additional arguments. | ||
|
|
||
| Returns: | ||
| A `CompressedList` from the 'compressed_lists' package. | ||
| """ | ||
| return read_compressed_string_list(robject, **kwargs) | ||
|
|
||
|
|
||
| def read_compressed_boolean_list(robject: dict, **kwargs): | ||
| """Read an R compressed boolean list. | ||
|
|
||
| Args: | ||
| robject: | ||
| Dictionary containing parsed compressed list. | ||
|
|
||
| **kwargs: | ||
| Additional arguments. | ||
|
|
||
| Returns: | ||
| A `CompressedList` from the 'compressed_lists' package. | ||
| """ | ||
| _cls = get_class(robject) | ||
|
|
||
| if _cls not in ["CompressedLogicalList"]: | ||
| raise RuntimeError(f"`robject` does not contain not a compressed boolean list object, contains `{_cls}`.") | ||
|
|
||
| unlist_data, element_metadata, metadata, partition = _get_compressed_common_attrs(robject=robject, **kwargs) | ||
|
|
||
| from compressed_lists import CompressedBooleanList | ||
|
|
||
| return CompressedBooleanList( | ||
| unlist_data=unlist_data, partitioning=partition, element_metadata=element_metadata, metadata=metadata | ||
| ) | ||
|
|
||
|
|
||
| def read_compressed_float_list(robject: dict, **kwargs): | ||
| """Read an R compressed float list. | ||
|
|
||
| Args: | ||
| robject: | ||
| Dictionary containing parsed compressed list. | ||
|
|
||
| **kwargs: | ||
| Additional arguments. | ||
|
|
||
| Returns: | ||
| A `CompressedList` from the 'compressed_lists' package. | ||
| """ | ||
| _cls = get_class(robject) | ||
|
|
||
| if _cls not in ["CompressedNumericList"]: | ||
| raise RuntimeError(f"`robject` does not contain not a compressed float list object, contains `{_cls}`.") | ||
|
|
||
| unlist_data, element_metadata, metadata, partition = _get_compressed_common_attrs(robject=robject, **kwargs) | ||
|
|
||
| from compressed_lists import CompressedFloatList | ||
|
|
||
| return CompressedFloatList( | ||
| unlist_data=unlist_data, partitioning=partition, element_metadata=element_metadata, metadata=metadata | ||
| ) | ||
|
|
||
|
|
||
| def read_compressed_frame_list(robject: dict, **kwargs): | ||
| """Read an R compressed dataframe list. | ||
|
|
||
| Args: | ||
| robject: | ||
| Dictionary containing parsed compressed list. | ||
|
|
||
| **kwargs: | ||
| Additional arguments. | ||
|
|
||
| Returns: | ||
| A `CompressedList` from the 'compressed_lists' package. | ||
| """ | ||
| _cls = get_class(robject) | ||
|
|
||
| if _cls not in ["CompressedSplitDataFrameList", "CompressedSplitDFrameList"]: | ||
| raise RuntimeError(f"`robject` does not contain not a compressed dataframe list object, contains `{_cls}`.") | ||
|
|
||
| unlist_data, element_metadata, metadata, partition = _get_compressed_common_attrs(robject=robject, **kwargs) | ||
|
|
||
| from compressed_lists import CompressedSplitBiocFrameList | ||
|
|
||
| return CompressedSplitBiocFrameList( | ||
| unlist_data=unlist_data, partitioning=partition, element_metadata=element_metadata, metadata=metadata | ||
| ) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| import pytest | ||
|
|
||
| from rds2py import read_rds | ||
|
|
||
| from biocutils import BooleanList, FloatList, IntegerList, StringList | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Unpinned tag for a non-immutable Action in workflow Medium