-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
292 additions
and
13 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,54 @@ | ||
import dask_nested as dn | ||
import nested_pandas as npd | ||
import numpy as np | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def test_dataset(): | ||
"""create a toy dataset for testing purposes""" | ||
n_base = 50 | ||
layer_size = 500 | ||
randomstate = np.random.RandomState(seed=1) | ||
|
||
# Generate base data | ||
base_data = {"a": randomstate.random(n_base), "b": randomstate.random(n_base) * 2} | ||
base_nf = npd.NestedFrame(data=base_data) | ||
|
||
layer_data = { | ||
"t": randomstate.random(layer_size * n_base) * 20, | ||
"flux": randomstate.random(layer_size * n_base) * 100, | ||
"band": randomstate.choice(["r", "g"], size=layer_size * n_base), | ||
"index": np.arange(layer_size * n_base) % n_base, | ||
} | ||
layer_nf = npd.NestedFrame(data=layer_data).set_index("index") | ||
|
||
base_dn = dn.NestedFrame.from_nestedpandas(base_nf, npartitions=5) | ||
layer_dn = dn.NestedFrame.from_nestedpandas(layer_nf, npartitions=10) | ||
|
||
return base_dn.add_nested(layer_dn, "nested") | ||
|
||
|
||
@pytest.fixture | ||
def test_dataset_no_add_nested(): | ||
"""stop before add_nested""" | ||
n_base = 50 | ||
layer_size = 500 | ||
randomstate = np.random.RandomState(seed=1) | ||
|
||
# Generate base data | ||
base_data = {"a": randomstate.random(n_base), "b": randomstate.random(n_base) * 2} | ||
base_nf = npd.NestedFrame(data=base_data) | ||
|
||
layer_data = { | ||
"t": randomstate.random(layer_size * n_base) * 20, | ||
"flux": randomstate.random(layer_size * n_base) * 100, | ||
"band": randomstate.choice(["r", "g"], size=layer_size * n_base), | ||
"index": np.arange(layer_size * n_base) % n_base, | ||
} | ||
layer_nf = npd.NestedFrame(data=layer_data).set_index("index") | ||
|
||
base_dn = dn.NestedFrame.from_nestedpandas(base_nf, npartitions=5) | ||
layer_dn = dn.NestedFrame.from_nestedpandas(layer_nf, npartitions=10) | ||
|
||
return (base_dn, layer_dn) |
This file was deleted.
Oops, something went wrong.
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,51 @@ | ||
import dask_nested as dn | ||
from nested_pandas.series.dtype import NestedDtype | ||
|
||
|
||
def test_nestedframe_construction(test_dataset): | ||
"""test the construction of a nestedframe""" | ||
pass | ||
|
||
|
||
def test_all_columns(test_dataset): | ||
"""all_columns property test""" | ||
pass | ||
|
||
|
||
def test_nested_columns(test_dataset): | ||
"""nested_columns property test""" | ||
pass | ||
|
||
|
||
def test_add_nested(test_dataset_no_add_nested): | ||
"""test the add_nested function""" | ||
base, layer = test_dataset_no_add_nested | ||
|
||
base_with_nested = base.add_nested(layer, "nested") | ||
|
||
# Check that the result is a nestedframe | ||
assert isinstance(base_with_nested, dn.NestedFrame) | ||
|
||
# Check that there's a new nested column with the correct dtype | ||
assert "nested" in base_with_nested.columns | ||
assert isinstance(base_with_nested.dtypes["nested"], NestedDtype) | ||
|
||
# Check that the nested partitions were used | ||
assert base_with_nested.npartitions == 10 | ||
|
||
assert len(base_with_nested.compute()) == 50 | ||
|
||
|
||
def test_query(test_dataset): | ||
"""test the query function""" | ||
pass | ||
|
||
|
||
def test_dropna(test_dataset): | ||
"""test the dropna function""" | ||
pass | ||
|
||
|
||
def test_reduce(test_dataset): | ||
"""test the reduce function""" | ||
pass |