diff --git a/CTools/Exceptions/MultiplexersExceptions.py b/CTools/Exceptions/MultiplexersExceptions.py deleted file mode 100644 index 15bb830..0000000 --- a/CTools/Exceptions/MultiplexersExceptions.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -PyCircTools Multiplexer module Exceptions. -""" - - -class MultiplexerException(Exception): - """ - MultiplexerException is the parent Exception class for all PyCircTools.Multiplexers related Exceptions - """ - def __init__(self, msg="Multiplexer Exception"): - self.msg = msg - super().__init__(self.msg) - - -class NonExistingInput(MultiplexerException): - """ - NonExistingInput is raised when a Multiplexer/Demultiplexer doesn't have the input asked for. - """ - def __init__(self, requestedInput=None): - if requestedInput is not None: - self.msg = "Input " + str(requestedInput) + " does not exist." - else: - self.msg = "Input requested does not exist." - super().__init__(self.msg) diff --git a/CTools/Exceptions/__init__.py b/CTools/Exceptions/__init__.py index 2e7c0d3..76b9bc5 100644 --- a/CTools/Exceptions/__init__.py +++ b/CTools/Exceptions/__init__.py @@ -4,4 +4,3 @@ from CTools.Exceptions.CircuitToolsExceptions import * from CTools.Exceptions.LogicGateExceptions import * -from CTools.Exceptions.MultiplexersExceptions import * diff --git a/tests/Multiplexers_tests/__init__.py b/CTools/Modules/__init__.py similarity index 100% rename from tests/Multiplexers_tests/__init__.py rename to CTools/Modules/__init__.py diff --git a/CTools/Multiplexers/Mux2to1.py b/CTools/Multiplexers/Mux2to1.py deleted file mode 100644 index ee8c05e..0000000 --- a/CTools/Multiplexers/Mux2to1.py +++ /dev/null @@ -1,93 +0,0 @@ -from CTools.Exceptions.MultiplexersExceptions import NonExistingInput -from CTools.Exceptions.CircuitToolsExceptions import NotTruthValue - - -class Mux2to1: - """ - 2 to 1 Multiplexer. Takes one Set input. - """ - def __init__(self): - """ - Mux2to1 class constructor method. - """ - self.input = [False, False] - self.set = False - self.output = self.__calculate_output() - - def get_input(self, num): - """ - Method get_input is used to get the value of input[num] - - :param num: Number of the input you want to get, either 0 or 1. - :type num: int - :raises NonExistingInput: raised when a Multiplexer/Demultiplexer doesn't have the input asked for. - :return: Value of the desired input (num). - :rtype: bool - """ - if num >= len(self.input) or num < 0: - raise NonExistingInput(num) - - return self.input[num] - - def get_set(self): - """ - Method get_set gets the value of the set control signal. - - :return: Value of the set control signal. - :rtype: bool - """ - return self.set - - def get_output(self): - """ - Method get_output gets the output of the 2 to 1 Multiplexer. - - :return: Value of the output - :rtype: bool - """ - return self.output - - def set_input(self, num, value): - """ - Method set_input sets a certain input to the desired value, either True or False. - - :param num: Number of the input selected. - :type num: int - :param value: Desired value of the input. - :type value: bool - :raises NonExistingInput: raised when a Multiplexer/Demultiplexer doesn't have the input asked for. - :raises NotTruthValue: Raised when value's type is not bool. - """ - if num >= len(self.input) or num < 0: - raise NonExistingInput(num) - - if type(value) is not bool: - raise NotTruthValue - - self.input[num] = value - self.output = self.__calculate_output() - return self - - def set_set(self, value): - """ - Method set_set sets the value of the set control signal to the desired truth value. - - :param value: Desired value of the set control signal. - :type value: bool - :raises NotTruthValue: Raised when value's type is not bool. - """ - if type(value) is not bool: - raise NotTruthValue - - self.set = value - self.output = self.__calculate_output() - return self - - def __calculate_output(self): - """ - Private method __calculate_output calculates the output signal using the 2-to-1 mux formula. - - :return: Value of the output signal. - :rtype: bool - """ - return (self.input[0] and not(self.set)) or (self.input[1] and self.set) diff --git a/CTools/Multiplexers/__init__.py b/CTools/Multiplexers/__init__.py deleted file mode 100644 index 38604cd..0000000 --- a/CTools/Multiplexers/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -""" -PyCircTools Multiplexers package. - -This package includes some Multiplexers and Demultiplexers (from 1 to 2 to 1 to 16) -""" - -from CTools.Multiplexers.Mux2to1 import * diff --git a/CTools/__init__.py b/CTools/__init__.py index 520d9e2..e326bfd 100644 --- a/CTools/__init__.py +++ b/CTools/__init__.py @@ -5,4 +5,3 @@ from CTools.Exceptions import * from CTools.LogicGates import * -from CTools.Multiplexers import * diff --git a/setup.py b/setup.py index 4061783..266dcb6 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name='PyCircTools', packages=find_packages(include=['Exceptions', 'LogicGates']), - version='0.0.3', + version='0.0.1', description='CTools, a python circuit library.', author='LovetheFrogs', license='GPL-3.0', diff --git a/tests/Multiplexers_tests/test_Mux2to1.py b/tests/Multiplexers_tests/test_Mux2to1.py deleted file mode 100644 index 0139c3e..0000000 --- a/tests/Multiplexers_tests/test_Mux2to1.py +++ /dev/null @@ -1,45 +0,0 @@ -from CTools import NotTruthValue, NonExistingInput -from CTools.Multiplexers import Mux2to1 - - -def test_Mux2to1(): - errors = [] - mux = Mux2to1() - - if mux.get_output(): - errors.append("Base get output test not passed!") - - if mux.set_set(True).get_output(): - errors.append("False, False with set to True test not passed!") - - if mux.set_input(1, True).set_set(False).get_output(): - errors.append("False, True with set to False test not passed!") - - if not mux.set_set(True).get_output(): - errors.append("False, True with set to True test not passed!") - - if not mux.set_input(0, True).set_input(1, False).set_set(False).get_output(): - errors.append("True, False with set to False test not passed!") - - if mux.set_set(True).get_output(): - errors.append("True, False with set to True test not passed!") - - if not mux.set_input(1, True).set_set(False).get_output(): - errors.append("True, True with set to False test not passed!") - - if not mux.set_set(True).get_output(): - errors.append("True, True with set to True test not passed!") - - try: - mux.set_set(1) - errors.append("Set to not truth test not passed!") - except NotTruthValue: - pass - - try: - mux.set_input(-1, True) - errors.append("Input to not existing input test not passed!") - except NonExistingInput: - pass - - assert not errors, "errors occured:\n{}".format("\n".join(errors))