FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Expand fastai tests · handlerww/docker-python@7b7dfd6 · GitHub

Commit 7b7dfd6

Browse files
committed
Expand fastai tests
1 parent 8ceb312 commit 7b7dfd6

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎tests/test_fastai.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
11
import unittest
22

3+
import fastai
4+
import pandas as pd
5+
import torch
6+
7+
from fastai.docs import *
8+
from fastai.tabular import *
39
from fastai.core import partition
10+
from fastai.torch_core import tensor
411

512
class TestFastAI(unittest.TestCase):
613
def test_partition(self):
714
result = partition([1,2,3,4,5], 2)
815

916
self.assertEqual(3, len(result))
17+
18+
def test_has_version(self):
19+
self.assertGreater(len(fastai.__version__), 1)
20+
21+
# based on https://github.com/fastai/fastai/blob/master/tests/test_torch_core.py#L17
22+
def test_torch_tensor(self):
23+
a = tensor([1, 2, 3])
24+
b = torch.tensor([1, 2, 3])
25+
26+
self.assertTrue(torch.all(a == b))
27+
28+
def test_tabular(self):
29+
df = pd.read_csv("/input/tests/data/train.csv")
30+
31+
train_df, valid_df = df[:-5].copy(),df[-5:].copy()
32+
dep_var = "label"
33+
cont_names = []
34+
for i in range(784):
35+
cont_names.append("pixel" + str(i))
36+
37+
data = tabular_data_from_df("", train_df, valid_df, dep_var, cont_names=cont_names, cat_names=[])
38+
learn = get_tabular_learner(data, layers=[200, 100])
39+
learn.fit(epochs=1)

‎tests/test_pandas.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class TestPandas(unittest.TestCase):
66
def test_read_csv(self):
77
data = pd.read_csv("/input/tests/data/train.csv")
88

9-
self.assertEqual(14915, data.size)
9+
self.assertEqual(19, len(data.index))
1010

1111
def test_read_feather(self):
1212
data = pd.read_feather("/input/tests/data/feather-0_3_1.feather")

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL