-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate bag and array tests from dask
- Loading branch information
Showing
2 changed files
with
51 additions
and
50 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
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,38 @@ | ||
import pytest | ||
|
||
pytest.importorskip('dask.bag') | ||
|
||
from odo import chunks, TextFile, odo | ||
from dask.bag import Bag | ||
from odo.utils import filetexts | ||
|
||
|
||
def inc(x): | ||
return x + 1 | ||
|
||
|
||
dsk = {('x', 0): (range, 5), | ||
('x', 1): (range, 5), | ||
('x', 2): (range, 5)} | ||
|
||
L = list(range(5)) * 3 | ||
|
||
b = Bag(dsk, 'x', 3) | ||
|
||
|
||
def test_convert_bag_to_list(): | ||
assert odo(b, list) == L | ||
|
||
|
||
def test_convert_logfiles_to_bag(): | ||
with filetexts({'a1.log': 'Hello\nWorld', 'a2.log': 'Hola\nMundo'}) as fns: | ||
logs = chunks(TextFile)(list(map(TextFile, fns))) | ||
b = odo(logs, Bag) | ||
assert isinstance(b, Bag) | ||
assert 'a1.log' in str(b.dask.values()) | ||
assert odo(b, list) == odo(logs, list) | ||
|
||
|
||
def test_sequence(): | ||
b = odo([1, 2, 3], Bag) | ||
assert set(b.map(inc)) == set([2, 3, 4]) |