Пример #1
0
 def setUp(self):
     self.txtfile = "juego.txt"
     self.txtfile1 = "juego1.txt"
     self.csvfile = "juego.csv"
     self.readvalidtxt = ReadFiles("juego.txt")
     self.readinvalidtxt = ReadFiles("juego1.txt")
     self.readvalidcsv = ReadFiles("juego.csv")
     self.readinvalidcsv = ReadFiles("juego1.csv")
     self.invalidfile = ReadFiles("hola.png")
Пример #2
0
 def setUp(self):
     self.txtfile = "juego.txt"
     self.txtfile1 = "juego1.txt"
     self.csvfile = "juego.csv"
     self.readvalidtxt = ReadFiles("juego.txt")
     self.readinvalidtxt = ReadFiles("juego1.txt")
     self.readvalidcsv = ReadFiles("juego.csv")
     self.readinvalidcsv = ReadFiles("juego1.csv")
     self.invalidfile = ReadFiles("hola.png")
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr  1 14:34:37 2020

@author: findlayforsblom
"""

import numpy as np
from readfiles import ReadFiles
import pandas as pd
from sklearn.model_selection import cross_val_predict

files = ReadFiles([
    './Datasets/SnowDepth.csv', './Datasets/Airtemperature.csv',
    './Datasets/Precipitation.csv', './Datasets/FallAmount.csv',
    './Datasets/humidity.csv'
])
dataset = files.createDataset()
dataset = dataset[dataset['Temp'] < 10]
X = dataset.iloc[:, [1, 3, 4, 6, 5]].values
y = dataset.iloc[:, 2].values

# Encoding categorical data
df = pd.DataFrame(
    data=X,
    columns=['Snow depth', 'Temp', 'dummy', 'Humidity', 'Precipiattion'])
just_dummies = pd.get_dummies(df['dummy'])

df = pd.concat([df, just_dummies], axis=1)
df.drop(['dummy'], inplace=True, axis=1)
Пример #4
0
class TestReadFiles(unittest.TestCase):
    def setUp(self):
        self.txtfile = "juego.txt"
        self.txtfile1 = "juego1.txt"
        self.csvfile = "juego.csv"
        self.readvalidtxt = ReadFiles("juego.txt")
        self.readinvalidtxt = ReadFiles("juego1.txt")
        self.readvalidcsv = ReadFiles("juego.csv")
        self.readinvalidcsv = ReadFiles("juego1.csv")
        self.invalidfile = ReadFiles("hola.png")

    def test_if_gettype_verifies_a_txt_file(self):
        expected = "TXT File"
        self.assertEqual(expected, self.readvalidtxt.gettype())

    def test_if_gettype_verifies_a_csv_file(self):
        expected = "CSV File"
        self.assertEqual(expected, self.readvalidcsv.gettype())

    def test_if_gettype_verifies_another_file_extension(self):
        expected = "invalid extension"
        self.assertEqual(expected, self.invalidfile.gettype())

    def test_if_solver_is_able_to_read_a_txt_file(self):
        f1 = open(self.txtfile, 'r')
        expected = f1.read()
        self.assertEqual(expected, self.readvalidtxt.reading_txt())

    def test_if_txt_has_a_matrix_of_9x9(self):
        expected = 81
        self.assertEqual(expected, self.readvalidtxt.validate_size_txt())

    def test_if_alert_message_is_displayed_for_non_valid_dimentions_in_txt_file(
            self):
        expected = "The dimensions inserted are invalid"
        self.assertEqual(expected, self.readinvalidtxt.validate_size_txt())

    def test_if_txt_has_values_from_0_to_9(self):
        expected = True  # ??????
        self.assertEqual(expected, self.readvalidtxt.validate_values_txt())

    def test_if_alert_message_is_displayed_for_non_valid_values_in_txt_file(
            self):
        expected = "The values from txt files are invalid"
        self.assertEqual(expected, self.readinvalidtxt.validate_values_txt())

    def test_if_solver_is_able_to_read_a_csv_file(self):
        with open(self.csvfile, 'rb') as csvfile:
            expected = list(csv.reader(csvfile))
        self.assertEqual(expected, self.readvalidcsv.reading_csv())

    def test_if_csv_has_a_matrix_of_9x9(self):
        expected = 81
        self.assertEqual(expected, self.readvalidcsv.validate_size_csv())

    def test_if_alert_message_is_displayed_for_non_valid_dimentions_in_csv_file(
            self):
        expected = "The dimensions inserted are invalid"
        self.assertEqual(expected, self.readinvalidcsv.validate_size_csv())

    def test_if_csv_has_values_from_0_to_9(self):
        expected = True
        self.assertEqual(expected, self.readvalidcsv.validate_values_csv())

    def test_if_alert_message_is_displayed_for_non_valid_values_in_csv_file(
            self):
        expected = "The values from csv files are invalid"
        self.assertEqual(expected, self.readinvalidcsv.validate_values_csv())
Пример #5
0
class TestReadFiles(unittest.TestCase):
    def setUp(self):
        self.txtfile = "juego.txt"
        self.txtfile1 = "juego1.txt"
        self.csvfile = "juego.csv"
        self.readvalidtxt = ReadFiles("juego.txt")
        self.readinvalidtxt = ReadFiles("juego1.txt")
        self.readvalidcsv = ReadFiles("juego.csv")
        self.readinvalidcsv = ReadFiles("juego1.csv")
        self.invalidfile = ReadFiles("hola.png")
               
    def test_if_gettype_verifies_a_txt_file(self):
        expected = "TXT File"
        self.assertEqual(expected, self.readvalidtxt.gettype())

    def test_if_gettype_verifies_a_csv_file(self):
        expected = "CSV File"
        self.assertEqual(expected, self.readvalidcsv.gettype())

    def test_if_gettype_verifies_another_file_extension(self):
        expected = "invalid extension"
        self.assertEqual(expected, self.invalidfile.gettype())

    def test_if_solver_is_able_to_read_a_txt_file(self):
        f1 = open(self.txtfile,'r')
        expected = f1.read()
        self.assertEqual(expected, self.readvalidtxt.reading_txt())

    def test_if_txt_has_a_matrix_of_9x9(self):
        expected = 81
        self.assertEqual(expected,self.readvalidtxt.validate_size_txt())

    def test_if_alert_message_is_displayed_for_non_valid_dimentions_in_txt_file(self):
        expected = "The dimensions inserted are invalid"
        self.assertEqual(expected,self.readinvalidtxt.validate_size_txt())

    def test_if_txt_has_values_from_0_to_9(self):
        expected = True  # ??????
        self.assertEqual(expected, self.readvalidtxt.validate_values_txt())

    def test_if_alert_message_is_displayed_for_non_valid_values_in_txt_file(self):
        expected = "The values from txt files are invalid"
        self.assertEqual(expected,self.readinvalidtxt.validate_values_txt())

    def test_if_solver_is_able_to_read_a_csv_file(self):
        with open (self.csvfile,'rb') as csvfile:
            expected = list(csv.reader(csvfile))
        self.assertEqual(expected, self.readvalidcsv.reading_csv())

    def test_if_csv_has_a_matrix_of_9x9(self):
        expected = 81
        self.assertEqual(expected,self.readvalidcsv.validate_size_csv())

    def test_if_alert_message_is_displayed_for_non_valid_dimentions_in_csv_file(self):
        expected = "The dimensions inserted are invalid"
        self.assertEqual(expected,self.readinvalidcsv.validate_size_csv())

    def test_if_csv_has_values_from_0_to_9(self):
        expected = True
        self.assertEqual(expected,self.readvalidcsv.validate_values_csv())

    def test_if_alert_message_is_displayed_for_non_valid_values_in_csv_file(self):
        expected = "The values from csv files are invalid"
        self.assertEqual(expected,self.readinvalidcsv.validate_values_csv())