Skip to content

Commit ffc6b95

Browse files
committed
2 parents 471a3c5 + e466aad commit ffc6b95

5 files changed

Lines changed: 105 additions & 0 deletions

File tree

test/test_convert_to_numeric.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pandas as pd
2+
from to_numeric import convert_to_numeric
3+
4+
def test_convert_to_numeric():
5+
6+
df = pd.DataFrame({'A': ['1', '2', '3'], 'B': ['4.5', '5.6', '6.7'], 'C': ['a', 'b', 'c']})
7+
8+
9+
convert_to_numeric(df, 'A')
10+
11+
12+
assert df['A'][0],int

test/test_heatmap_corr.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
import seaborn as sns
4+
import pandas as pd
5+
from heatmap_corr import heatmap
6+
7+
def test_heatmap():
8+
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9], 'target': [10, 20, 30]})
9+
10+
heatmap(df, 2, 'target', None)
11+
12+
13+

test/test_log_transform_data.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import pandas as pd
2+
import numpy as np
3+
import re
4+
from datetime import datetime
5+
from typing import List
6+
from nltk.corpus import stopwords
7+
from nltk.stem.snowball import SnowballStemmer
8+
import cv2
9+
import os
10+
from skimage.io import imread
11+
import sys
12+
import pytest
13+
14+
sys.path.append('/home/sean/Documentos/the_bridge_bootcamp/My_Workspaces/MachineLearningToolKit/toolkit')
15+
from data_processing import log_transform_data
16+
17+
18+
def test_log_transform_data_ignore():
19+
df = pd.DataFrame({'a':[0, 0, 1, 0],
20+
'b': [16, 7, 6, 16],
21+
'c':[61, 57, 16, 36],
22+
'd':['12','22','13','44'],
23+
'e':['Green','Red','Blue','Yellow'],
24+
'f':[1, 11, 23, 66]})
25+
26+
df_processed = log_transform_data(df, col_ignore = ['a'])
27+
28+
pd.testing.assert_frame_equal(df[['a', 'd', 'e']], df_processed[['a', 'd', 'e']])
29+
30+
31+
def test_log_transform_data_log():
32+
df = pd.DataFrame({'a':[0, 0, 1, 0],
33+
'b': [16, 7, 6, 16],
34+
'c':[61, 57, 16, 36],
35+
'd':['12','22','13','44'],
36+
'e':['Green','Red','Blue','Yellow'],
37+
'f':[1, 11, 23, 66]})
38+
39+
df_processed = log_transform_data(df, col_ignore = ['a'])
40+
41+
pd.testing.assert_frame_equal(df_processed[['b']], pd.DataFrame(np.log1p(df['b'])))

test/test_scrap.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from selenium import webdriver
2+
from selenium.webdriver.common.by import By
3+
import requests
4+
from bs4 import BeautifulSoup
5+
from selenium import webdriver
6+
import os
7+
import time
8+
import io
9+
from PIL import Image
10+
from scrap import image_scrap
11+
import shutil
12+
13+
14+
def test_image_scrap():
15+
url = 'https://www.google.com/search?q=perros+bonitos&tbm=isch&ved=2ahUKEwiCpOG3z6n9AhVFV6QEHY7KBa0Q2-cCegQIABAA&oq=perros+bonitos&gs_lcp=CgNpbWcQAzIFCAAQgAQyBQgAEIAEMgUIABCABDIFCAAQgAQyBQgAEIAEMgUIABCABDIFCAAQgAQyBAgAEB4yBAgAEB4yBAgAEB5QwAlY6hFg6hJoAHAAeACAAYgBiAHJBpIBAzcuMpgBAKABAaoBC2d3cy13aXotaW1nwAEB&sclient=img&ei=YUz2Y8LvFMWukdUPjpWX6Ao&bih=849&biw=1600&rlz=1C5CHFA_enCA951CA951'
16+
n = 5
17+
image_scrap(url,n)
18+
19+
download_dir = './my_images'
20+
21+
assert os.path.exists(download_dir)
22+
assert len(os.listdir(download_dir)) == n
23+
24+
shutil.rmtree(download_dir)

test/test_sunburst.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from sunburst import sunburst
2+
import plotly.graph_objs as go
3+
import plotly.express as px
4+
5+
def test_sunburst():
6+
df = {
7+
'Category': ['Fruit', 'Fruit', 'Vegetable', 'Vegetable', 'Vegetable'],
8+
'Subcategory': ['Apple', 'Orange', 'Carrot', 'Tomato', 'Cucumber'],
9+
'Value': [20, 30, 40, 15, 25] }
10+
11+
fig = sunburst(df, 'Category', 'Subcategory', 'Value', 'My Sunburst Chart')
12+
13+
assert fig.layout.title.text == 'My Sunburst Chart'
14+
assert fig.layout.width == 800
15+
assert fig.layout.height == 600

0 commit comments

Comments
 (0)