-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from BirkhoffG/integration_tests
Add integration tests
- Loading branch information
Showing
5 changed files
with
131 additions
and
5 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,12 @@ | ||
import jax_dataloader as jdl | ||
import numpy as np | ||
import datasets as hfds | ||
|
||
|
||
def test_hf(): | ||
ds = hfds.Dataset.from_dict({"feats": np.ones((10, 3)), "labels": np.ones((10, 3))}) | ||
dl = jdl.DataLoader(ds, 'jax', batch_size=2) | ||
for batch in dl: | ||
x, y = batch['feats'], batch['labels'] | ||
z = x + y | ||
assert isinstance(z, np.ndarray) |
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 @@ | ||
import jax_dataloader as jdl | ||
import jax.numpy as jnp | ||
import pytest | ||
|
||
|
||
def test_jax(): | ||
ds = jdl.ArrayDataset(jnp.ones((10, 3)), jnp.ones((10, 3))) | ||
assert len(ds) == 10 | ||
dl = jdl.DataLoader(ds, 'jax', batch_size=2) | ||
for x, y in dl: | ||
z = x + y | ||
|
||
|
||
def test_torch(): | ||
with pytest.raises(ModuleNotFoundError): | ||
ds = jdl.ArrayDataset(jnp.ones((10, 3)), jnp.ones((10, 3))) | ||
dl = jdl.DataLoader(ds, 'pytorch', batch_size=2) | ||
for x, y in dl: z = x + y | ||
|
||
|
||
def test_tf(): | ||
with pytest.raises(ModuleNotFoundError): | ||
ds = jdl.ArrayDataset(jnp.ones((10, 3)), jnp.ones((10, 3))) | ||
dl = jdl.DataLoader(ds, 'tensorflow', batch_size=2) | ||
for x, y in dl: z = x + y | ||
|
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,21 @@ | ||
import jax_dataloader as jdl | ||
import numpy as np | ||
import tensorflow_datasets as tfds | ||
import tensorflow as tf | ||
|
||
|
||
def test_jax(): | ||
ds = jdl.ArrayDataset(np.ones((10, 3)), np.ones((10, 3))) | ||
dl = jdl.DataLoader(ds, 'tensorflow', batch_size=2) | ||
for x, y in dl: | ||
z = x + y | ||
assert isinstance(z, np.ndarray) | ||
|
||
|
||
def test_tf(): | ||
ds = tf.data.Dataset.from_tensor_slices((tf.ones((10, 3)), tf.ones((10, 3)))) | ||
dl = jdl.DataLoader(ds, 'tensorflow', batch_size=2) | ||
for x, y in dl: | ||
z = x + y | ||
assert isinstance(z, np.ndarray) | ||
|
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,22 @@ | ||
import jax_dataloader as jdl | ||
import torch | ||
import numpy as np | ||
import jax.numpy as jnp | ||
from torch.utils.data import TensorDataset | ||
|
||
|
||
def test_jax_ds(): | ||
ds = jdl.ArrayDataset(jnp.ones((10, 3)), jnp.ones((10, 3))) | ||
assert len(ds) == 10 | ||
dl = jdl.DataLoader(ds, 'pytorch', batch_size=2) | ||
for x, y in dl: | ||
z = x + y | ||
|
||
|
||
def test_torch(): | ||
ds = TensorDataset(torch.ones((10, 3)), torch.ones((10, 3))) | ||
dl = jdl.DataLoader(ds, 'pytorch', batch_size=2) | ||
for x, y in dl: | ||
z = x + y | ||
assert isinstance(z, np.ndarray) | ||
|