forked from activeloopai/deeplake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increased test coverage by 4%. Many tests implemented, legacy code ex…
…cluded from coverage.
- Loading branch information
1 parent
1fdaa54
commit 6ce13d8
Showing
9 changed files
with
228 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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,3 +1,2 @@ | ||
[run] | ||
omit = */tests/* | ||
|
||
omit = */tests/*, hub/collections/*, hub/codec/* |
This file contains 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 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 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,3 @@ | ||
alpha | ||
beta | ||
gamma |
This file contains 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,26 @@ | ||
from hub.features.class_label import ClassLabel, _load_names_from_file | ||
|
||
names_file = "./hub/features/tests/class_label_names.txt" | ||
|
||
|
||
def test_load_names_from_file(): | ||
assert _load_names_from_file(names_file) == [ | ||
"alpha", | ||
"beta", | ||
"gamma", | ||
] | ||
|
||
|
||
def test_class_label(): | ||
bel1 = ClassLabel(num_classes=4) | ||
bel2 = ClassLabel(names=["alpha", "beta", "gamma"]) | ||
ClassLabel(names_file=names_file) | ||
assert bel1.names == ["0", "1", "2", "3"] | ||
assert bel2.names == ["alpha", "beta", "gamma"] | ||
assert bel1.str2int("1") == 1 | ||
assert bel2.str2int("gamma") == 2 | ||
assert bel1.int2str(2) is None # FIXME This is a bug, should raise an error | ||
assert bel2.int2str(0) == "alpha" | ||
assert bel1.num_classes == 4 | ||
assert bel2.num_classes == 3 | ||
bel1.get_attr_dict() |
This file contains 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 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 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,23 @@ | ||
from hub.store.nested_store import NestedStore | ||
|
||
import zarr | ||
|
||
|
||
def test_nested_store(): | ||
store = NestedStore(zarr.MemoryStore(), "hello") | ||
store["item"] = bytes("Hello World", "utf-8") | ||
assert store["item"] == bytes("Hello World", "utf-8") | ||
del store["item"] | ||
assert store.get("item") is None | ||
store["item1"] = bytes("Hello World 1", "utf-8") | ||
store["item2"] = bytes("Hello World 2", "utf-8") | ||
assert len(store) == 2 | ||
assert tuple(store) == ("item1", "item2") | ||
try: | ||
store.commit() | ||
except AttributeError as ex: | ||
assert "'MemoryStore' object has no attribute 'commit'" in str(ex) | ||
|
||
|
||
if __name__ == "__main__": | ||
test_nested_store() |
Oops, something went wrong.