# Path: dcs/clean.py
# def fillDown(df, columnFrom, columnTo, method):
# def fillByInterpolation(df, columnIndex, method, order):
# def fillWithCustomValue(df, columnIndex, newValue):
# def fillWithAverage(df, columnIndex, metric):
# def normalize(df, columnIndex, rangeFrom=0, rangeTo=1):
# def standardize(df, columnIndex):
# def deleteRowsWithNA(df, columnIndex):
# def findReplace(df, columnIndex, toReplace, replaceWith, matchRegex):
# def generateDummies(df, columnIndex, inplace):
# def insertDuplicateColumn(df, columnIndex):
# def splitColumn(df, columnIndex, delimiter, regex=False):
# def combineColumns(df, columnHeadings, seperator="", newName="merged_column", insertIndex=0):
# def discretize(df, columnIndex, cutMode, numberOfBins):
# def executeCommand(df, command):


import numpy as np
import pandas as pd
import pytest
from dcs import clean
def test_split_delimeter3():
	testing_df = df.copy()
	testing_df['col4'] = pd.Series(['hello.world', 'world.hello', 'p.4q', 'r', 's'])
	result_df = testing_df.copy()
	clean.splitColumn(testing_df, 3, '\.', regex=True)
	result_df['col4_0'] = pd.Series(['hello', 'world', 'p','r', 's'])
	result_df['col4_1'] = pd.Series(['world', 'hello', '4q'])
	assert (((testing_df.fillna(0) == result_df.fillna(0)).all()).all()) == True

#test splitting a column that dose not exist
def test_split_delimeter4():
	testing_df = df.copy()
	with pytest.raises(Exception):
		clean.splitColumn(testing_df, 7, '.') 

#--------------------------------------(Combine Columns)---------------------------------------

#test combining two columns that contain some NA values
def test_combine1():
	testing_df = df.copy()
	result_df = df.copy()
	clean.combineColumns(testing_df, ['col1', 'col2'], seperator=' ', newName="combined")
	result_df.insert(0, 'combined', ['1.0 1.0', '2.0 2.0', '2.0', '3.0', '4.0 4.0'], allow_duplicates=True)
	assert (((testing_df.fillna(0) == result_df.fillna(0)).all()).all()) == True

#test combining less than two columns
def test_combine2():
	testing_df = df.copy()
	result_df = df.copy()
	with pytest.raises(Exception):

# Path: dcs/clean.py
# def fillDown(df, columnFrom, columnTo, method):
# def fillByInterpolation(df, columnIndex, method, order):
# def fillWithCustomValue(df, columnIndex, newValue):
# def fillWithAverage(df, columnIndex, metric):
# def normalize(df, columnIndex, rangeFrom=0, rangeTo=1):
# def standardize(df, columnIndex):
# def deleteRowsWithNA(df, columnIndex):
# def findReplace(df, columnIndex, toReplace, replaceWith, matchRegex):
# def generateDummies(df, columnIndex, inplace):
# def insertDuplicateColumn(df, columnIndex):
# def splitColumn(df, columnIndex, delimiter, regex=False):
# def combineColumns(df, columnHeadings, seperator="", newName="merged_column", insertIndex=0):
# def discretize(df, columnIndex, cutMode, numberOfBins):
# def executeCommand(df, command):


# Path: dcs/testing/test_clean_module.py
import numpy as np
import pandas as pd
import pytest
from dcs import clean

def test_split_delimeter3():
	testing_df = df.copy()
	testing_df['col4'] = pd.Series(['hello.world', 'world.hello', 'p.4q', 'r', 's'])
	result_df = testing_df.copy()
	clean.splitColumn(testing_df, 3, '\.', regex=True)
	result_df['col4_0'] = pd.Series(['hello', 'world', 'p','r', 's'])
	result_df['col4_1'] = pd.Series(['world', 'hello', '4q'])
	assert (((testing_df.fillna(0) == result_df.fillna(0)).all()).all()) == True

#test splitting a column that dose not exist
def test_split_delimeter4():
	testing_df = df.copy()
	with pytest.raises(Exception):
		clean.splitColumn(testing_df, 7, '.') 

#--------------------------------------(Combine Columns)---------------------------------------

#test combining two columns that contain some NA values
def test_combine1():
	testing_df = df.copy()
	result_df = df.copy()
	clean.combineColumns(testing_df, ['col1', 'col2'], seperator=' ', newName="combined")
	result_df.insert(0, 'combined', ['1.0 1.0', '2.0 2.0', '2.0', '3.0', '4.0 4.0'], allow_duplicates=True)
	assert (((testing_df.fillna(0) == result_df.fillna(0)).all()).all()) == True

#test combining less than two columns
def test_combine2():
	testing_df = df.copy()
	result_df = df.copy()
	with pytest.raises(Exception):

		clean.combineColumns(testing_df, ['col1'], seperator=' ', newName="combined")