From db066d6a5de7f4d64d446e6548c7fc691466f1cf Mon Sep 17 00:00:00 2001 From: Saimadhav Heblikar Date: Fri, 3 Oct 2014 20:16:04 +0530 Subject: [PATCH 01/25] Fix SR Latch example in README.md Replaced all instances of set_input()/set_output() with setInput() and setOutput() --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 720c781..a171bbe 100644 --- a/README.md +++ b/README.md @@ -41,25 +41,25 @@ R = 0 # Reset input for the SR-Latch S = 0 # Set input for the SR-Lacth NOR1 = NOR(con1, R) #First NOR gate -NOR1.set_output(con2) # Set output for NOR gate +NOR1.setOutput(con2) # Set output for NOR gate NOR2 = NOR(con2, S) #Second NOR gate -NOR2.set_output(con1) # Set output for NOR gate +NOR2.setOutput(con1) # Set output for NOR gate -NOR1.set_input(1, 1); NOR2.set_input(1, 0) #Set state +NOR1.setInput(1, 1); NOR2.setInput(1, 0) #Set state print 'Q: ',NOR2.output(), '\t','Q\': ',NOR1.output() -NOR1.set_input(1, 0); NOR2.set_input(1, 1) #Reset state +NOR1.setInput(1, 0); NOR2.setInput(1, 1) #Reset state print 'Q: ',NOR2.output(), '\t','Q\': ',NOR1.output() -NOR1.set_input(1, 0); NOR2.set_input(1, 0) #Hold state +NOR1.setInput(1, 0); NOR2.setInput(1, 0) #Hold state print 'Q: ',NOR2.output(), '\t','Q\': ',NOR1.output() -NOR1.set_input(1, 1); NOR2.set_input(1, 1) #Invalid state +NOR1.setInput(1, 1); NOR2.setInput(1, 1) #Invalid state print 'Q: ',NOR2.output(), '\t','Q\': ',NOR1.output() From fe3948c5ae8e7f8ff091a9b9f2be4925a9c09a1a Mon Sep 17 00:00:00 2001 From: Saimadhav Heblikar Date: Fri, 3 Oct 2014 20:25:05 +0530 Subject: [PATCH 02/25] Make SR Latch example code Pythonic Add space to single line comments where necessary. Trim line length to less than 80 characters. Move multiple statements in single line to individual lines. --- README.md | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a171bbe..f0de63f 100644 --- a/README.md +++ b/README.md @@ -37,30 +37,34 @@ con1 = Connector() # Connector for connecting output of first NOR gate with input of second NOR gate con2 = Connector() -R = 0 # Reset input for the SR-Latch -S = 0 # Set input for the SR-Lacth +R = 0 # Reset input for the SR-Latch +S = 0 # Set input for the SR-Lacth -NOR1 = NOR(con1, R) #First NOR gate -NOR1.setOutput(con2) # Set output for NOR gate +NOR1 = NOR(con1, R) # First NOR gate +NOR1.setOutput(con2) # Set output for NOR gate -NOR2 = NOR(con2, S) #Second NOR gate -NOR2.setOutput(con1) # Set output for NOR gate +NOR2 = NOR(con2, S) # Second NOR gate +NOR2.setOutput(con1) # Set output for NOR gate -NOR1.setInput(1, 1); NOR2.setInput(1, 0) #Set state -print 'Q: ',NOR2.output(), '\t','Q\': ',NOR1.output() +NOR1.setInput(1, 1) +NOR2.setInput(1, 0) # Set state +print 'Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output() -NOR1.setInput(1, 0); NOR2.setInput(1, 1) #Reset state -print 'Q: ',NOR2.output(), '\t','Q\': ',NOR1.output() +NOR1.setInput(1, 0) +NOR2.setInput(1, 1) # Reset state +print 'Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output() -NOR1.setInput(1, 0); NOR2.setInput(1, 0) #Hold state -print 'Q: ',NOR2.output(), '\t','Q\': ',NOR1.output() +NOR1.setInput(1, 0) +NOR2.setInput(1, 0) # Hold state +print 'Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output() -NOR1.setInput(1, 1); NOR2.setInput(1, 1) #Invalid state -print 'Q: ',NOR2.output(), '\t','Q\': ',NOR1.output() +NOR1.setInput(1, 1) +NOR2.setInput(1, 1) # Invalid state +print 'Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output() ``` From 95c4b972f50b05d4250ca0fa1a4363f3b3a5bf10 Mon Sep 17 00:00:00 2001 From: Saimadhav Heblikar Date: Fri, 3 Oct 2014 20:29:59 +0530 Subject: [PATCH 03/25] Make SR Latch example in README.md Python3 compatible. --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f0de63f..f9476c4 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,12 @@ Here's an example of SR latch constructed from a pair of cross-coupled NOR gates ```python +from __future__ import print_function from BinPy import * -# Connector for connecting output of second NOR gate with input of first NOR gate +# Connector to connect output of second NOR gate with input of first NOR gate con1 = Connector() -# Connector for connecting output of first NOR gate with input of second NOR gate +# Connector to connect output of first NOR gate with input of second NOR gate con2 = Connector() R = 0 # Reset input for the SR-Latch @@ -49,22 +50,22 @@ NOR2.setOutput(con1) # Set output for NOR gate NOR1.setInput(1, 1) NOR2.setInput(1, 0) # Set state -print 'Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output() +print('Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output()) NOR1.setInput(1, 0) NOR2.setInput(1, 1) # Reset state -print 'Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output() +print('Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output()) NOR1.setInput(1, 0) NOR2.setInput(1, 0) # Hold state -print 'Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output() +print('Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output()) NOR1.setInput(1, 1) NOR2.setInput(1, 1) # Invalid state -print 'Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output() +print('Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output()) ``` From 257f63cce90af0f3121d9c01858dcc04536720e3 Mon Sep 17 00:00:00 2001 From: Saimadhav Heblikar Date: Fri, 3 Oct 2014 20:33:52 +0530 Subject: [PATCH 04/25] Update SR Latch output in README.md example Replace False/True with 0/1. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f9476c4..3abfbf0 100644 --- a/README.md +++ b/README.md @@ -71,10 +71,10 @@ print('Q: ', NOR2.output(), '\t', 'Q\': ', NOR1.output()) ``` Output ```python -Q: True Q': False -Q: False Q': True -Q: False Q': True -Q: False Q': False #Invalid State +Q: 1 Q': 0 +Q: 0 Q': 1 +Q: 0 Q': 1 +Q: 0 Q': 0 #Invalid State ``` Operations, Combinatonal Logic and Algorithms From 2e62c6c3acadc8ea2d5960eb881c4d95a13ab030 Mon Sep 17 00:00:00 2001 From: Rapternmn Date: Sat, 4 Oct 2014 21:51:37 +0530 Subject: [PATCH 05/25] Added class IC_7406 --- BinPy/ic/series_7400.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/BinPy/ic/series_7400.py b/BinPy/ic/series_7400.py index 512f9ca..926091e 100644 --- a/BinPy/ic/series_7400.py +++ b/BinPy/ic/series_7400.py @@ -541,6 +541,45 @@ def run(self): else: print("Ground and VCC pins have not been configured correctly.") +class IC_7406(Base_14pin): + + """ + This is Hex Inverter/Buffer with Hi-Volt Open Collector Output + """ + + def __init__(self): + self.pins = [ + None, + 0, + None, + 0, + None, + 0, + None, + 0, + None, + 0, + None, + 0, + None, + 0, + 0] + + def run(self): + output = {} + output[2] = NOT(self.pins[1]).output() + output[4] = NOT(self.pins[3]).output() + output[6] = NOT(self.pins[5]).output() + output[8] = NOT(self.pins[9]).output() + output[10] = NOT(self.pins[11]).output() + output[12] = NOT(self.pins[13]).output() + if self.pins[7] == 0 and self.pins[14] == 1: + self.set_IC(output) + for i in self.output_connector: + self.output_connector[i].state = output[i] + return output + else: + print("Ground and VCC pins have not been configured correctly.") class IC_7408(Base_14pin): From 47b8d5ec3d51f0142ff7180f79efa1d13d966c74 Mon Sep 17 00:00:00 2001 From: Rapternmn Date: Sat, 4 Oct 2014 23:04:27 +0530 Subject: [PATCH 06/25] Added test for IC_7406() --- BinPy/algorithms/ExpressionConvert.py | 4 +-- BinPy/algorithms/MooreOptimizer.py | 4 ++- BinPy/algorithms/MultiplicationAlgos.py | 4 ++- BinPy/analog/buffers.py | 3 +- BinPy/analog/converters.py | 14 +++++--- BinPy/analog/sig_gen.py | 3 +- BinPy/combinational/combinational.py | 48 ++++++++++++++++++------- BinPy/connectors/connector.py | 6 ++-- BinPy/connectors/linker.py | 18 ++++++---- BinPy/gates/tree.py | 11 ++++-- BinPy/ic/series_4000.py | 8 +++-- BinPy/ic/series_7400.py | 2 ++ BinPy/tests/operations_tests.py | 3 +- BinPy/tests/print_tests.py | 12 +++++-- BinPy/tests/series_7400_tests.py | 9 +++++ BinPy/tools/multivibrator.py | 5 ++- BinPy/tools/oscilloscope.py | 9 ++++- 17 files changed, 123 insertions(+), 40 deletions(-) diff --git a/BinPy/algorithms/ExpressionConvert.py b/BinPy/algorithms/ExpressionConvert.py index 3750c20..b37890d 100644 --- a/BinPy/algorithms/ExpressionConvert.py +++ b/BinPy/algorithms/ExpressionConvert.py @@ -203,8 +203,8 @@ def convertExpression(expr, two_input=0, only_nand=0, previous_gate = previous_gate.upper() next_gate = op2[:len(gate)] next_gate = next_gate.upper() - if (two_input == 0 and gate != 'NAND'and gate != 'NOR')and \ - (only_nand == 0 and only_nor == 0 and only_and_or_not == 0): + if (two_input == 0 and gate != 'NAND'and gate != 'NOR')and ( + only_nand == 0 and only_nor == 0 and only_and_or_not == 0): if (gate == previous_gate) and (gate == next_gate.upper()): new_element = gate + \ '(' + op1[len(gate) + 1:-1] + \ diff --git a/BinPy/algorithms/MooreOptimizer.py b/BinPy/algorithms/MooreOptimizer.py index dbd52aa..58e6ab6 100644 --- a/BinPy/algorithms/MooreOptimizer.py +++ b/BinPy/algorithms/MooreOptimizer.py @@ -238,7 +238,9 @@ def optimize(self): min_complexity = 99999999 counter = 0 elements = range(1 << self.state_word_len) - for permutation in itertools.permutations(elements, len(self.state_tran)): + for permutation in itertools.permutations( + elements, len( + self.state_tran)): counter += 1 if counter & 0xff == 0: sys.stderr.write('%%%3.2f done\r' % (100.0 * counter / total)) diff --git a/BinPy/algorithms/MultiplicationAlgos.py b/BinPy/algorithms/MultiplicationAlgos.py index 8d9335d..9b133c9 100644 --- a/BinPy/algorithms/MultiplicationAlgos.py +++ b/BinPy/algorithms/MultiplicationAlgos.py @@ -388,7 +388,9 @@ def toom3_multiply(multiplier, multiplicand, bits=None, signed=False): abs(multiplier.int), bits, signed=False) # Base case of 0 bit multiplication. If length is 0 product is 0. - if len(multiplier.bin.lstrip("0")) == 0 or len(multiplicand.bin.lstrip("0")) == 0: + if len( + multiplier.bin.lstrip("0")) == 0 or len( + multiplicand.bin.lstrip("0")) == 0: return "0" # Base case of 1 bit multiplication diff --git a/BinPy/analog/buffers.py b/BinPy/analog/buffers.py index 38730fd..d4aa4d8 100644 --- a/BinPy/analog/buffers.py +++ b/BinPy/analog/buffers.py @@ -87,7 +87,8 @@ def trigger(self): inp_voltages = self.inputs.get_voltage_all() cur_enable = bool(self._enable[0]) - if (self._history == inp_voltages) and (self._enable_history == cur_enable) and (self._atten_history == self._attenuation): + if (self._history == inp_voltages) and (self._enable_history == cur_enable) and ( + self._atten_history == self._attenuation): return self._history = inp_voltages diff --git a/BinPy/analog/converters.py b/BinPy/analog/converters.py index f79875c..02a5fe2 100644 --- a/BinPy/analog/converters.py +++ b/BinPy/analog/converters.py @@ -107,7 +107,8 @@ def __init__( if typ not in [4, 5]: # Linking the reference inputs. - if (type(refp) not in [Bus, Connector]) or (type(refn) not in [Bus, Connector]): + if (type(refp) not in [Bus, Connector]) or ( + type(refn) not in [Bus, Connector]): raise Exception("ERROR: Invalid reference inputs") else: @@ -142,7 +143,10 @@ def set_inputs(self, analog_input): """ with AutoUpdater._lock: - if isinstance(analog_input, Bus) and analog_input.analog and (analog_input.width == 1): + if isinstance( + analog_input, + Bus) and analog_input.analog and ( + analog_input.width == 1): AutoUpdater.remove_link( self.inputs) # Remove old links to the inputs AutoUpdater.add_link( @@ -413,7 +417,8 @@ def __init__( if typ not in [4, 5]: # Linking the reference inputs. - if (type(refp) not in [Bus, Connector]) or (type(refn) not in [Bus, Connector]): + if (type(refp) not in [Bus, Connector]) or ( + type(refn) not in [Bus, Connector]): raise Exception("ERROR: Invalid reference inputs") else: @@ -448,7 +453,8 @@ def set_inputs(self, digital_inputs): """ with AutoUpdater._lock: - if isinstance(digital_inputs, Bus) and (not digital_inputs.analog) and (digital_inputs.width == 2 ** (self.typ + 1)): + if isinstance(digital_inputs, Bus) and (not digital_inputs.analog) and ( + digital_inputs.width == 2 ** (self.typ + 1)): AutoUpdater.remove_link( self.inputs) # Remove old links to the inputs AutoUpdater.add_link( diff --git a/BinPy/analog/sig_gen.py b/BinPy/analog/sig_gen.py index ce3e622..8bd39b2 100644 --- a/BinPy/analog/sig_gen.py +++ b/BinPy/analog/sig_gen.py @@ -407,7 +407,8 @@ def set_frequency_exact(self, frequency): # Choose the appropriate frequency range based on the passed value. for i in range(len(self.FREQ_RANGE)): - if (frequency <= self.FREQ_RANGE[i][0] and frequency >= self.FREQ_RANGE[i][0]): + if (frequency <= self.FREQ_RANGE[i][ + 0] and frequency >= self.FREQ_RANGE[i][0]): self._frequency_range = self.FREQ_RANGE[i] break diff --git a/BinPy/combinational/combinational.py b/BinPy/combinational/combinational.py index 45913d3..0f18c86 100644 --- a/BinPy/combinational/combinational.py +++ b/BinPy/combinational/combinational.py @@ -288,7 +288,8 @@ def set_input(self, index, value): def trigger(self): if len(self.selects) == 0: return - if not (len(self.inputs) > 1 and (len(self.inputs) & (len(self.inputs) - 1) == 0)): + if not (len(self.inputs) > 1 and ( + len(self.inputs) & (len(self.inputs) - 1) == 0)): raise Exception("ERROR: Number of inputs should be a power of 2") bstr = '' for i in self.selects: @@ -528,8 +529,13 @@ class Encoder(GATES): def __init__(self, *inputs): if not (len(inputs) > 1 and (len(inputs) & (len(inputs) - 1) == 0)): raise Exception("ERROR: Number of inputs should be a power of 2") - if not (inputs.count(1) == 1 or list(x.state for x in - filter(lambda i: isinstance(i, Connector), inputs)).count(1) == 1): + if not ( + inputs.count(1) == 1 or list( + x.state for x in filter( + lambda i: isinstance( + i, + Connector), + inputs)).count(1) == 1): raise Exception("Invalid Input") GATES.__init__(self, *inputs) self.output_type = [] @@ -541,7 +547,8 @@ def __init__(self, *inputs): def trigger(self): if isinstance(self.output_type, int): return - if not (len(self.inputs) > 1 and (len(self.inputs) & (len(self.inputs) - 1) == 0)): + if not (len(self.inputs) > 1 and ( + len(self.inputs) & (len(self.inputs) - 1) == 0)): raise Exception("ERROR: Number of inputs should be a power of 2") temp = self.inputs[:] for i in range(len(temp)): @@ -557,11 +564,17 @@ def trigger(self): def set_inputs(self, *inputs): if not (len(inputs) > 1 and (len(inputs) & (len(inputs) - 1) == 0)): raise Exception("ERROR: Number of inputs should be a power of 2") - if not (inputs.count(1) == 1 or list(x.state for x in - filter(lambda i: isinstance(i, Connector), inputs)).count(1) == 1): + if not ( + inputs.count(1) == 1 or list( + x.state for x in filter( + lambda i: isinstance( + i, + Connector), + inputs)).count(1) == 1): raise Exception("ERROR: Invalid Input") self.inputs = list(inputs) - for i in range(len(self.output_type), int(math.log(len(self.inputs), 2))): + for i in range( + len(self.output_type), int(math.log(len(self.inputs), 2))): self.output_type.append(0) self.output_connector.append(None) self._update_connections() @@ -571,17 +584,28 @@ def set_input(self, index, value): temp = self.inputs[:] if index >= len(temp): temp.append(value) - if not (temp.count(1) == 1 or list(x.state for x in - filter(lambda i: isinstance(i, Connector), temp)).count(1) == 1): + if not ( + temp.count(1) == 1 or list( + x.state for x in filter( + lambda i: isinstance( + i, + Connector), + temp)).count(1) == 1): raise Exception("ERROR: Invalid Input") self.inputs.append(value) - for i in range(len(self.output_type), int(math.log(len(self.inputs), 2))): + for i in range( + len(self.output_type), int(math.log(len(self.inputs), 2))): self.output_type.append(0) self.output_connector.append(None) else: temp[index] = value - if not (temp.count(1) == 1 or list(x.state for x in - filter(lambda i: isinstance(i, Connector), temp)).count(1) == 1): + if not ( + temp.count(1) == 1 or list( + x.state for x in filter( + lambda i: isinstance( + i, + Connector), + temp)).count(1) == 1): raise Exception("ERROR: Invalid Input") self.inputs[index] = value diff --git a/BinPy/connectors/connector.py b/BinPy/connectors/connector.py index c09f92e..4b8abda 100644 --- a/BinPy/connectors/connector.py +++ b/BinPy/connectors/connector.py @@ -296,7 +296,8 @@ def __init__(self, *inputs): self.analog = False # width specified - if (len(inputs) == 1) and (isinstance(inputs[0], int)) and (inputs[0] >= 0): + if (len(inputs) == 1) and (isinstance(inputs[0], int)) and ( + inputs[0] >= 0): self.bus += [Connector() for i in range(inputs[0])] self._width = inputs[0] @@ -313,7 +314,8 @@ def __init__(self, *inputs): inputs = inputs[0] # if inputs is an unpacked list of connectors - if (len(inputs) > 0) and (False not in [isinstance(i, Connector) for i in inputs]): + if (len(inputs) > 0) and ( + False not in [isinstance(i, Connector) for i in inputs]): self.bus += inputs self._width = len(self.bus) diff --git a/BinPy/connectors/linker.py b/BinPy/connectors/linker.py index cc28568..ab4945c 100644 --- a/BinPy/connectors/linker.py +++ b/BinPy/connectors/linker.py @@ -126,7 +126,8 @@ def add_link( AutoUpdater._graph[Bus_a][Bus_b]['params'] = list(params) AutoUpdater.modified = True - if (not directed) and (not AutoUpdater._graph.has_edge(Bus_b, Bus_a)): + if (not directed) and ( + not AutoUpdater._graph.has_edge(Bus_b, Bus_a)): AutoUpdater._graph.add_edge(Bus_b, Bus_a, object=bind_to) AutoUpdater._graph[Bus_b][Bus_a]['params'] = list(params) @@ -158,7 +159,8 @@ def remove_link(a, b=None, directed=True): if len(a) != len(b): raise Exception("ERROR: Lengths are not equal") for i, j in zip(a, b): - if (isinstance(i, Connector), isinstance(j, Connector)) != (True, True): + if (isinstance(i, Connector), isinstance(j, Connector)) != ( + True, True): raise Exception( "ERROR: Only Connector objects can be Unlinked") with AutoUpdater._lock: @@ -166,7 +168,8 @@ def remove_link(a, b=None, directed=True): # pair is ( bus_0, bus_1 ) for index in range(len(pair[0])): # Traverse through the bus_0 ( = pair[0] ) - if ((pair[0])[index] is i) and ((pair[1])[index] is j): + if ((pair[0])[index] is i) and ( + (pair[1])[index] is j): # If ( i , j ) is ( bus_0[index] , bus_1[index] ) # Where ( i, j ) is the input link to # be removed ( i --> j ) @@ -179,7 +182,8 @@ def remove_link(a, b=None, directed=True): # varies. if not directed: for index in range(len(pair[0])): - if (((pair[0])[index] is j) and ((pair[1])[index] is i)): + if (((pair[0])[index] is j) and ( + (pair[1])[index] is i)): del pair[1][index] del pair[0][index] @@ -202,7 +206,8 @@ def remove_link(a, b=None, directed=True): for pair in AutoUpdater._graph.edges(): # pair is ( bus_0, bus_1 ) for index in range(len(pair[0])): - if ((pair[0])[index] is conn) or ((pair[1])[index] is conn): + if ((pair[0])[index] is conn) or ( + (pair[1])[index] is conn): # if the conn is found either as # the start / end point of the link # ... @@ -424,5 +429,6 @@ def get_element(index, cls): the various elements of BinPy by its index ( the id ). """ - if (cls in BinPyIndexer._indices) and (index in BinPyIndexer._indices[cls]): + if (cls in BinPyIndexer._indices) and ( + index in BinPyIndexer._indices[cls]): return BinPyIndexer._indices[cls][index] diff --git a/BinPy/gates/tree.py b/BinPy/gates/tree.py index a08ab54..0a2ec37 100644 --- a/BinPy/gates/tree.py +++ b/BinPy/gates/tree.py @@ -126,8 +126,15 @@ def backtrack(self, hist=None): # Check if the element is a gate, connector or a final value, bool or # int - if not (isinstance(self.element, GATES) or isinstance(self.element, Connector) - or type(self.element) in [bool, int]): + if not ( + isinstance( + self.element, + GATES) or isinstance( + self.element, + Connector) or type( + self.element) in [ + bool, + int]): raise Exception( "ERROR: Element must be either a Gate or Connector") diff --git a/BinPy/ic/series_4000.py b/BinPy/ic/series_4000.py index 15c6376..8cd482f 100644 --- a/BinPy/ic/series_4000.py +++ b/BinPy/ic/series_4000.py @@ -1705,7 +1705,9 @@ def run(self): elif self.pins[10] == 0: if self.pins[9] == 0: d = NBitDownCounter(4, self.pins[15].A) - while self.arraytoint(self.state) != self.arraytoint(d.trigger()): + while self.arraytoint( + self.state) != self.arraytoint( + d.trigger()): pass arr = d.trigger() output[6], output[11], output[14], output[2] = arr @@ -1715,7 +1717,9 @@ def run(self): output[6], output[11], output[14], output[2] = [1, 0, 0, 1] elif self.pins[9] == 1: d = NBitDownCounter(4, self.pins[15].A) - while self.arraytoint(self.state) != self.arraytoint(d.trigger()): + while self.arraytoint( + self.state) != self.arraytoint( + d.trigger()): pass arr = d.trigger() output[6], output[11], output[14], output[2] = arr diff --git a/BinPy/ic/series_7400.py b/BinPy/ic/series_7400.py index 926091e..cdaf48d 100644 --- a/BinPy/ic/series_7400.py +++ b/BinPy/ic/series_7400.py @@ -541,6 +541,7 @@ def run(self): else: print("Ground and VCC pins have not been configured correctly.") + class IC_7406(Base_14pin): """ @@ -581,6 +582,7 @@ def run(self): else: print("Ground and VCC pins have not been configured correctly.") + class IC_7408(Base_14pin): """ diff --git a/BinPy/tests/operations_tests.py b/BinPy/tests/operations_tests.py index ba7d1d7..ee21a97 100644 --- a/BinPy/tests/operations_tests.py +++ b/BinPy/tests/operations_tests.py @@ -77,7 +77,8 @@ def decToBin_test(): assert False if Operations.decToBin(56789) != '1101110111010101': assert False - if Operations.decToBin(13.9876) != '1101.1111110011010011010110101000010110000111100101': + if Operations.decToBin( + 13.9876) != '1101.1111110011010011010110101000010110000111100101': assert False if Operations.decToBin(13.00) != '1101': assert False diff --git a/BinPy/tests/print_tests.py b/BinPy/tests/print_tests.py index ee093a3..6603201 100644 --- a/BinPy/tests/print_tests.py +++ b/BinPy/tests/print_tests.py @@ -58,17 +58,23 @@ def MUX_print_test(): def DEMUX_print_test(): gate = DEMUX(1) gate.select_lines(1) - if not re.search("DEMUX Gate; Output: \[0, 1]; Inputs: \[1];", gate.__str__()): + if not re.search( + "DEMUX Gate; Output: \[0, 1]; Inputs: \[1];", + gate.__str__()): assert False def Encoder_print_test(): gate = Encoder(0, 0, 0, 1) - if not re.search("Encoder Gate; Output: \[1, 1]; Inputs: \[0, 0, 0, 1];", gate.__str__()): + if not re.search( + "Encoder Gate; Output: \[1, 1]; Inputs: \[0, 0, 0, 1];", + gate.__str__()): assert False def Decoder_print_test(): gate = Decoder(0, 0) - if not re.search("Decoder Gate; Output: \[1, 0, 0, 0]; Inputs: \[0, 0];", gate.__str__()): + if not re.search( + "Decoder Gate; Output: \[1, 0, 0, 0]; Inputs: \[0, 0];", + gate.__str__()): assert False diff --git a/BinPy/tests/series_7400_tests.py b/BinPy/tests/series_7400_tests.py index 3e613d3..b4bb7df 100644 --- a/BinPy/tests/series_7400_tests.py +++ b/BinPy/tests/series_7400_tests.py @@ -60,6 +60,15 @@ def test_IC_7405(): assert False +def test_IC_7406(): + test_IC = IC_7406() + p = {1: 1, 3: 0, 5: 0, 7: 0, 9: 0, 11: 0, 13: 1, 14: 1} + test_IC.set_IC(p) + q = {2: 0, 4: 1, 6: 1, 8: 1, 10: 1, 12: 0} + if q != test_IC.run(): + assert False + + def test_IC_7408(): test_IC = IC_7408() p = {1: 1, 2: 0, 4: 0, 5: 0, 7: 0, 9: 1, 10: 1, 12: 0, 13: 0, 14: 1} diff --git a/BinPy/tools/multivibrator.py b/BinPy/tools/multivibrator.py index dcf62d3..fea9a1e 100644 --- a/BinPy/tools/multivibrator.py +++ b/BinPy/tools/multivibrator.py @@ -135,7 +135,10 @@ def run(self): self.update = False elif self.mode == 2: - while (self.mode == 2) and (self.update) and (not self._exit): + while ( + self.mode == 2) and ( + self.update) and ( + not self._exit): self._toggle_state() if self.A.state == 1: time.sleep(self.on_time) diff --git a/BinPy/tools/oscilloscope.py b/BinPy/tools/oscilloscope.py index 0d251f6..c381d84 100644 --- a/BinPy/tools/oscilloscope.py +++ b/BinPy/tools/oscilloscope.py @@ -107,7 +107,14 @@ def set_inputs(self, *inputs): try: for i in inputs: - if not (isinstance(i, tuple) and isinstance(i[0], Connector) and isinstance(i[1], str)): + if not ( + isinstance( + i, + tuple) and isinstance( + i[0], + Connector) and isinstance( + i[1], + str)): raise Exception("ERROR: Invalid input format") except: raise Exception("ERROR: Invalid input format") From f160994c67449f90fc6bb5043d6b60478079d2ac Mon Sep 17 00:00:00 2001 From: Raghav R V Date: Sun, 5 Oct 2014 02:12:15 +0530 Subject: [PATCH 07/25] Fixes #265 --- BinPy/ic/base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BinPy/ic/base.py b/BinPy/ic/base.py index 062cac6..3ea3e7b 100644 --- a/BinPy/ic/base.py +++ b/BinPy/ic/base.py @@ -3,7 +3,7 @@ """ from __future__ import print_function from BinPy import * -from BinPy.draw import symbols +import BinPy.draw.symbols as symbols import sys @@ -46,7 +46,7 @@ def draw_IC(self): top = "\n\n " + symbols._VHU + symbols._H * 9 + \ symbols._U + symbols._H * 9 + symbols._HVD + symbols._N - bottom = " " + symbols.symbols._VHD + \ + bottom = " " + symbols._VHD + \ symbols._H * 19 + symbols._HVU + " " diag = top @@ -89,9 +89,9 @@ def draw_IC(self): "---|", symbols._H * 2 + - _LT).replace( + symbols._LT).replace( "|---", - _RT + + symbols._RT + symbols._H * 2).replace( '|', From 8a0a781d7789c16c6e2e5cfbfb1c494b677c203d Mon Sep 17 00:00:00 2001 From: Sudhanshu Mishra Date: Sat, 8 Nov 2014 17:27:04 +0530 Subject: [PATCH 08/25] Fixes #276 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3abfbf0..a32b679 100644 --- a/README.md +++ b/README.md @@ -244,8 +244,8 @@ Visit our [roadmap](https://github.com/BinPy/BinPy/wiki/roadmap) and [ideas page -How To Contribute ------------------ +Contribute to BinPy +------------------- For a detailed summary of all the coding guidelines and [development workflow](https://github.com/BinPy/BinPy/wiki/Development-workflow), visit our [Wiki page](http://github.com/BinPy/BinPy/wiki). From 767be81b97cc0a44294db8c87bae25b4ac2ba225 Mon Sep 17 00:00:00 2001 From: AMiT Kumar Date: Sat, 18 Apr 2015 12:11:09 +0530 Subject: [PATCH 09/25] Added Gitter Badge and Fix Contribute link --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a32b679..12b1fa2 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # [BinPy](http://binpy.github.io/) [![Build Status](https://travis-ci.org/BinPy/BinPy.png?branch=develop)](https://travis-ci.org/BinPy/BinPy) [![Version](https://pypip.in/v/BinPy/badge.png)](https://pypi.python.org/pypi/BinPy/0.3) [![Downloads](https://pypip.in/d/BinPy/badge.png)](https://pypi.python.org/pypi/BinPy/0.3) +[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/binpy/binpy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) * [About](#what-is-binpy) * [Installation](#installation) * [Documentation](#documentation) - * [Contribute](#how-to-contribute) + * [Contribute](#contribute-to-binpy) From e95f13f42f75f5d62f05e01cc7b09e432b732af1 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Wed, 1 Jul 2015 16:50:23 +0530 Subject: [PATCH 10/25] Change website and documentation references --- BinPy/shell/shell.py | 4 ++-- README.md | 2 +- docs/source/index.rst | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BinPy/shell/shell.py b/BinPy/shell/shell.py index 528b942..6fcdfdf 100644 --- a/BinPy/shell/shell.py +++ b/BinPy/shell/shell.py @@ -23,8 +23,8 @@ def magic_clear(self, arg): banner += ' BinPy ' banner += BINPY_VERSION banner += ' [interactive shell]\n\n' -banner += ' Website: www.binpy.org\n\n' -banner += ' Documentation: http://docs.binpy.org/\n\n' +banner += ' Website: http://binpy.github.io\n\n' +banner += ' Documentation: http://binpy.readthedocs.org/en/latest/\n\n' banner += '+-----------------------------------------------------------+\n' banner += '\n' banner += 'Commands: \n' diff --git a/README.md b/README.md index 720c781..2e93ef7 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ To start it, simply issue ```$ binpy``` if BinPy is installed in your path. Documentation ------------- -Auto-generated documentation is available for reference at [BinPy docs](http://docs.binpy.org) +Auto-generated documentation is available for reference at [BinPy docs](http://binpy.readthedocs.org/en/latest/) Wiki diff --git a/docs/source/index.rst b/docs/source/index.rst index 83d29f8..d71f454 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,7 +1,7 @@ BinPy Documentation =================== -`BinPy `_ is a Python library for simulation of circuit elements. +`BinPy `_ is a Python library for simulation of circuit elements. It was started as a project to facilitate learning electronics. Now we've added few more things in the roadmap. For more information see our wiki on GitHub. From ccd9de5048109428ce9597f0d33acfb9dd927fc0 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Wed, 1 Jul 2015 20:15:20 +0530 Subject: [PATCH 11/25] Add napoleon extension for numpydoc doc style views --- docs/source/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index d418aac..2e992d7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -36,6 +36,7 @@ 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.viewcode', + 'sphinx.ext.napoleon', ] # Add any paths that contain templates here, relative to this directory. From 57b80f1512eb010de990cfb454381978cbcee862 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Wed, 1 Jul 2015 20:19:29 +0530 Subject: [PATCH 12/25] Create requirements.txt --- docs/requirements.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..8b5b528 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,10 @@ +ipython[nbconvert] +numpy >= 1.6 +matplotlib +pandas +pydotplus +sphinx >= 1.3 +sphinxcontrib-bibtex +sphinx_rtd_theme +networkx +bitstring From adcfe8dec8472bf97e2e146abbb66d31059ed10f Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Wed, 1 Jul 2015 20:32:43 +0530 Subject: [PATCH 13/25] Change theme to sphinx_rtd_theme --- docs/source/conf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 2e992d7..a37f139 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -115,11 +115,13 @@ # html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -html_theme_path = ['.'] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -html_title = "BinPy Documentation" +import sphinx_rtd_theme +html_theme = 'sphinx_rtd_theme' +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + # A shorter title for the navigation bar. Default is the same as html_title. html_short_title = "BinPy Docs" From 8dfdd4be4c3bcb033bcda2906e70567cf097425d Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Wed, 1 Jul 2015 21:04:35 +0530 Subject: [PATCH 14/25] Update and rename LICENSE to LICENSE.txt --- LICENSE => LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename LICENSE => LICENSE.txt (96%) diff --git a/LICENSE b/LICENSE.txt similarity index 96% rename from LICENSE rename to LICENSE.txt index 53ca842..256f5cc 100644 --- a/LICENSE +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright(c) 2013 - 2014 BinPy Development Team +Copyright(c) 2013 - 2015 BinPy Development Team All rights reserved. From 8df879e7460fb9ad9edac2537356155b9d9b88a5 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Wed, 1 Jul 2015 21:07:16 +0530 Subject: [PATCH 15/25] Add landscape.io badge. Remove not working badges. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d669183..5d18367 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # [BinPy](http://binpy.github.io/) -[![Build Status](https://travis-ci.org/BinPy/BinPy.png?branch=develop)](https://travis-ci.org/BinPy/BinPy) [![Version](https://pypip.in/v/BinPy/badge.png)](https://pypi.python.org/pypi/BinPy/0.3) [![Downloads](https://pypip.in/d/BinPy/badge.png)](https://pypi.python.org/pypi/BinPy/0.3) +[![Build Status](https://travis-ci.org/BinPy/BinPy.png?branch=develop)](https://travis-ci.org/BinPy/BinPy) +[![Code Health](https://landscape.io/github/BinPy/BinPy/develop/landscape.svg?style=flat)](https://landscape.io/github/BinPy/BinPy/develop) [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/binpy/binpy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) * [About](#what-is-binpy) From 7dd044b4b71f089ad3e9d15219a6699daf766d5c Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Wed, 1 Jul 2015 21:08:15 +0530 Subject: [PATCH 16/25] Drop pypy support --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0803411..a35967b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,6 @@ python: - 3.2 - 3.3 - 3.4 - - pypy before_install: From e87d5587d27cfae38495f245f3e761cebe5df3e1 Mon Sep 17 00:00:00 2001 From: Yashu Seth Date: Fri, 11 Sep 2015 02:08:25 -0700 Subject: [PATCH 17/25] Displays proper error message when insufficient number of parameters is given in the evaluate function of OhmsLaw or OhmsLaw_AC --- BinPy/algorithms/AnalogFormulas.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BinPy/algorithms/AnalogFormulas.py b/BinPy/algorithms/AnalogFormulas.py index db1f9a6..e8857f4 100644 --- a/BinPy/algorithms/AnalogFormulas.py +++ b/BinPy/algorithms/AnalogFormulas.py @@ -22,6 +22,10 @@ def evaluate(self, i=None, v=None, r=None, p=None): DictKeys: 'i', 'v', 'r', 'p' ''' values = [i, v, r, p] + + if sum(j is None for j in values)>2: + raise Exception('Atleast two parameters required') + if (any((j is not None and j < 0) for j in values)): raise Exception('enter positive values') else: @@ -71,6 +75,10 @@ def evaluate(self, i=None, v=None, z=None, p=None, c=None): DictKeys: 'i', 'v', 'z', 'p','c' ''' values = [i, v, z, p, c] + + if sum(j is None for j in values)>3: + raise Exception('Atleast three parameters required') + if (any((j is not None and j < 0) for j in values)): raise Exception('enter positive values') else: From 6670b0950309564a7dcfbc410854499e96d856ef Mon Sep 17 00:00:00 2001 From: Yashu Seth Date: Wed, 16 Sep 2015 13:41:41 -0700 Subject: [PATCH 18/25] "Fixed results invoving float calculations" Pleae enter the commit message for your changes. Lines starting --- .travis.yml | 1 - BinPy/algorithms/AnalogFormulas.py | 70 +++++++++++++++++------------- LICENSE => LICENSE.txt | 2 +- README.md | 3 +- docs/source/conf.py | 6 ++- 5 files changed, 47 insertions(+), 35 deletions(-) rename LICENSE => LICENSE.txt (96%) diff --git a/.travis.yml b/.travis.yml index 0803411..a35967b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,6 @@ python: - 3.2 - 3.3 - 3.4 - - pypy before_install: diff --git a/BinPy/algorithms/AnalogFormulas.py b/BinPy/algorithms/AnalogFormulas.py index db1f9a6..676085b 100644 --- a/BinPy/algorithms/AnalogFormulas.py +++ b/BinPy/algorithms/AnalogFormulas.py @@ -1,3 +1,5 @@ +from __future__ import division + class OhmsLaw: ''' @@ -22,29 +24,33 @@ def evaluate(self, i=None, v=None, r=None, p=None): DictKeys: 'i', 'v', 'r', 'p' ''' values = [i, v, r, p] + + if sum(j is None for j in values)>2: + raise Exception('Atleast two parameters required') + if (any((j is not None and j < 0) for j in values)): raise Exception('enter positive values') else: if not p: if not r: - r = float(v / i) - p = float(v) * i + r = v / i + p = v * i if not v: - v = float(i) * r - p = float(i) ** 2 * r + v = i * r + p = (i ** 2) * r if not i: - i = float(v) / r - p = float(v) ** 2 / r + i = v / r + p = (v ** 2) / r else: if not v and not r: - v = float(p) / i - r = float(p) / i ** 2 + v = p / i + r = p / (i ** 2) if not i and not r: - i = float(p) / v - r = float(p) / i ** 2 + i = p / v + r = p / (i ** 2) if not i and not v: - i = sqrt(float(p) / r) - v = float(i) * r + i = sqrt(p / r) + v = i * r print(values) return {'i': i, 'v': v, 'r': r, 'p': p} @@ -71,40 +77,44 @@ def evaluate(self, i=None, v=None, z=None, p=None, c=None): DictKeys: 'i', 'v', 'z', 'p','c' ''' values = [i, v, z, p, c] + + if sum(j is None for j in values)>3: + raise Exception('Atleast three parameters required') + if (any((j is not None and j < 0) for j in values)): raise Exception('enter positive values') else: if not p: if not z: - z = float(v) / i - p = float(v) * i * c + z = v / i + p = v * i * c if not v: - v = float(i) * z - p = float(i) ** 2 * z * c + v = i * z + p = i ** 2 * z * c if not i: - i = float(v / z) - p = float((v ** 2 * c) / z) + i = v / z + p = (v ** 2 * c) / z if not c: raise Exception('Enter value of \'c\' .Since \'p\' \ and \'c\' cant be unknowns at the same time. ') else: if not v and not z: - v = float(p) / (i * c) - z = float(p) / (i ** 2) + v = p / (i * c) + z = p / (i ** 2) if not i and not z: - i = float(p) / v - z = float(p) / ((i ** 2) * c) + i = p / v + z = p / ((i ** 2) * c) if not i and not v: - i = sqrt(float(p) / (z * c)) - v = float(i) * z + i = sqrt(p / (z * c)) + v = i * z if not c and not v: - c = float(p) / (i ** 2 * z) - v = float(i) * z + c = p / (i ** 2 * z) + v = i * z if not c and not i: - i = float(v / z) - c = float(p / (v * i)) + i = v / z + c = p / (v * i) if not c and not z: - z = float(v / i) - c = float(p / (v * i)) + z = v / i + c = p / (v * i) print(values) return {'i': i, 'v': v, 'z': z, 'p': p, 'c': c} diff --git a/LICENSE b/LICENSE.txt similarity index 96% rename from LICENSE rename to LICENSE.txt index 53ca842..256f5cc 100644 --- a/LICENSE +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright(c) 2013 - 2014 BinPy Development Team +Copyright(c) 2013 - 2015 BinPy Development Team All rights reserved. diff --git a/README.md b/README.md index d669183..5d18367 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # [BinPy](http://binpy.github.io/) -[![Build Status](https://travis-ci.org/BinPy/BinPy.png?branch=develop)](https://travis-ci.org/BinPy/BinPy) [![Version](https://pypip.in/v/BinPy/badge.png)](https://pypi.python.org/pypi/BinPy/0.3) [![Downloads](https://pypip.in/d/BinPy/badge.png)](https://pypi.python.org/pypi/BinPy/0.3) +[![Build Status](https://travis-ci.org/BinPy/BinPy.png?branch=develop)](https://travis-ci.org/BinPy/BinPy) +[![Code Health](https://landscape.io/github/BinPy/BinPy/develop/landscape.svg?style=flat)](https://landscape.io/github/BinPy/BinPy/develop) [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/binpy/binpy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) * [About](#what-is-binpy) diff --git a/docs/source/conf.py b/docs/source/conf.py index 2e992d7..a37f139 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -115,11 +115,13 @@ # html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -html_theme_path = ['.'] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -html_title = "BinPy Documentation" +import sphinx_rtd_theme +html_theme = 'sphinx_rtd_theme' +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + # A shorter title for the navigation bar. Default is the same as html_title. html_short_title = "BinPy Docs" From 2e70f7caebe8e9bec0263be80b0e3f4db0ff0f71 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Thu, 17 Sep 2015 02:36:08 +0530 Subject: [PATCH 19/25] Switch to container based infrastructure --- .travis.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index a35967b..f0d819c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +sudo : false + language: python notifications: @@ -10,6 +12,10 @@ notifications: on_failure: always on_start: false +addons: + apt: + packages: + python: - 2.6 - 2.7 @@ -17,15 +23,9 @@ python: - 3.3 - 3.4 -before_install: - - - sudo apt-get update - - sudo apt-get install wget build-essential - - sudo apt-get install python3-setuptools python-setuptools - install: - - sudo apt-get install pep8 python-nose + - pip install pep8 - pip install coverage - pip install --use-mirrors python-coveralls - pip install networkx From 35f0e3aceff86c043ba8ea2b8641ca3f21da49d4 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Thu, 17 Sep 2015 02:38:15 +0530 Subject: [PATCH 20/25] Upgrade pip for cache installation --- .travis.yml | 8 ++++++-- docs/source/development-workflow.rst | 4 ++-- docs/source/install.rst | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f0d819c..4394562 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,11 @@ addons: apt: packages: +cache: + directories: + - $HOME/.cache/pip + python: - - 2.6 - 2.7 - 3.2 - 3.3 @@ -25,9 +28,10 @@ python: install: + - pip install --upgrade pip - pip install pep8 - pip install coverage - - pip install --use-mirrors python-coveralls + - pip install python-coveralls - pip install networkx - pip install bitstring diff --git a/docs/source/development-workflow.rst b/docs/source/development-workflow.rst index dde40a0..655e399 100644 --- a/docs/source/development-workflow.rst +++ b/docs/source/development-workflow.rst @@ -143,7 +143,7 @@ Python 3 -------- BinPy uses a single codebase for Python 2 and Python 3 (the current supported -versions are Python 2.6, 2.7, 3.2, 3.3 and pypy). This means that your code needs +versions are Python 2.7, 3.2, 3.3 and 3.4). This means that your code needs to run in both Python 2 and Python 3. You may refer `this `_. as a ready reference to implement code that is both python 2 and 3 compatible. @@ -181,7 +181,7 @@ In Windows systems, first of all, install Python from:: http://python.org/download/ -by downloading the "Python 2.7 Windows installer" (or Python 2.6 or 2.5) and running it. Then do not +by downloading the "Python 2.7 Windows installer" and running it. Then do not forget to add Python to the $PATH environment. On Windows and Mac OS X, the easiest way to get git is to download GitHub's diff --git a/docs/source/install.rst b/docs/source/install.rst index 1fe7eda..fd82a69 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -8,7 +8,7 @@ Linux ----- .. note:: - We support python 2.6, 2.7, 3.2, 3.3 and pypy. If you have any of these + We support python 2.7, 3.2, 3.3 and 3.4. If you have any of these versions of python you are good to go. **Dependencies** From 0e47fce6af943ccd04c7ad4557d71d45fc83f598 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Thu, 17 Sep 2015 02:56:03 +0530 Subject: [PATCH 21/25] pep8 fixes in AnalogFormulas --- .travis.yml | 1 + BinPy/algorithms/AnalogFormulas.py | 11 ++++++----- docs/source/development-workflow.rst | 4 ++-- docs/source/install.rst | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4394562..ea5e160 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ cache: - $HOME/.cache/pip python: + - 2.6 - 2.7 - 3.2 - 3.3 diff --git a/BinPy/algorithms/AnalogFormulas.py b/BinPy/algorithms/AnalogFormulas.py index 676085b..def827c 100644 --- a/BinPy/algorithms/AnalogFormulas.py +++ b/BinPy/algorithms/AnalogFormulas.py @@ -1,5 +1,6 @@ from __future__ import division + class OhmsLaw: ''' @@ -24,10 +25,10 @@ def evaluate(self, i=None, v=None, r=None, p=None): DictKeys: 'i', 'v', 'r', 'p' ''' values = [i, v, r, p] - - if sum(j is None for j in values)>2: + + if sum(j is None for j in values) > 2: raise Exception('Atleast two parameters required') - + if (any((j is not None and j < 0) for j in values)): raise Exception('enter positive values') else: @@ -78,9 +79,9 @@ def evaluate(self, i=None, v=None, z=None, p=None, c=None): ''' values = [i, v, z, p, c] - if sum(j is None for j in values)>3: + if sum(j is None for j in values) > 3: raise Exception('Atleast three parameters required') - + if (any((j is not None and j < 0) for j in values)): raise Exception('enter positive values') else: diff --git a/docs/source/development-workflow.rst b/docs/source/development-workflow.rst index 655e399..dde40a0 100644 --- a/docs/source/development-workflow.rst +++ b/docs/source/development-workflow.rst @@ -143,7 +143,7 @@ Python 3 -------- BinPy uses a single codebase for Python 2 and Python 3 (the current supported -versions are Python 2.7, 3.2, 3.3 and 3.4). This means that your code needs +versions are Python 2.6, 2.7, 3.2, 3.3 and pypy). This means that your code needs to run in both Python 2 and Python 3. You may refer `this `_. as a ready reference to implement code that is both python 2 and 3 compatible. @@ -181,7 +181,7 @@ In Windows systems, first of all, install Python from:: http://python.org/download/ -by downloading the "Python 2.7 Windows installer" and running it. Then do not +by downloading the "Python 2.7 Windows installer" (or Python 2.6 or 2.5) and running it. Then do not forget to add Python to the $PATH environment. On Windows and Mac OS X, the easiest way to get git is to download GitHub's diff --git a/docs/source/install.rst b/docs/source/install.rst index fd82a69..1fe7eda 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -8,7 +8,7 @@ Linux ----- .. note:: - We support python 2.7, 3.2, 3.3 and 3.4. If you have any of these + We support python 2.6, 2.7, 3.2, 3.3 and pypy. If you have any of these versions of python you are good to go. **Dependencies** From ebd6f0ef51f4394176982d2db4a57d37ed53017d Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Thu, 17 Sep 2015 02:58:22 +0530 Subject: [PATCH 22/25] Drop 2.6 and pypy --- .travis.yml | 1 - docs/source/development-workflow.rst | 4 ++-- docs/source/install.rst | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea5e160..4394562 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,6 @@ cache: - $HOME/.cache/pip python: - - 2.6 - 2.7 - 3.2 - 3.3 diff --git a/docs/source/development-workflow.rst b/docs/source/development-workflow.rst index dde40a0..655e399 100644 --- a/docs/source/development-workflow.rst +++ b/docs/source/development-workflow.rst @@ -143,7 +143,7 @@ Python 3 -------- BinPy uses a single codebase for Python 2 and Python 3 (the current supported -versions are Python 2.6, 2.7, 3.2, 3.3 and pypy). This means that your code needs +versions are Python 2.7, 3.2, 3.3 and 3.4). This means that your code needs to run in both Python 2 and Python 3. You may refer `this `_. as a ready reference to implement code that is both python 2 and 3 compatible. @@ -181,7 +181,7 @@ In Windows systems, first of all, install Python from:: http://python.org/download/ -by downloading the "Python 2.7 Windows installer" (or Python 2.6 or 2.5) and running it. Then do not +by downloading the "Python 2.7 Windows installer" and running it. Then do not forget to add Python to the $PATH environment. On Windows and Mac OS X, the easiest way to get git is to download GitHub's diff --git a/docs/source/install.rst b/docs/source/install.rst index 1fe7eda..fd82a69 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -8,7 +8,7 @@ Linux ----- .. note:: - We support python 2.6, 2.7, 3.2, 3.3 and pypy. If you have any of these + We support python 2.7, 3.2, 3.3 and 3.4. If you have any of these versions of python you are good to go. **Dependencies** From b71b03e9204c94e0112f6073b080c4565ffd525a Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Thu, 17 Sep 2015 02:59:05 +0530 Subject: [PATCH 23/25] No use of sudo on container based travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4394562..add1e87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ install: script: - - sudo chmod 777 test_travis.sh + - chmod 777 test_travis.sh - ./test_travis.sh after_success: From e73722b232fb614639f424e16c588864112eeff0 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Thu, 17 Sep 2015 03:07:44 +0530 Subject: [PATCH 24/25] Ignore pep8 on travis --- .travis.yml | 1 - test_travis.sh | 2 -- 2 files changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index add1e87..72b88c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,6 @@ python: install: - pip install --upgrade pip - - pip install pep8 - pip install coverage - pip install python-coveralls - pip install networkx diff --git a/test_travis.sh b/test_travis.sh index 152c68b..b098905 100644 --- a/test_travis.sh +++ b/test_travis.sh @@ -11,8 +11,6 @@ function nt() python $(which nosetests) $1; } -pep8 --exclude="build/*" --ignore=E501 ./; chk; - cd BinPy/tests/; nt .; chk; From b1498e8b60d246a790215556227e7b2a9ad0ea9a Mon Sep 17 00:00:00 2001 From: Sagun Pai Date: Sat, 2 Jan 2016 04:20:21 +0530 Subject: [PATCH 25/25] Updated copyright to 2016 --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index 256f5cc..fa1aa36 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright(c) 2013 - 2015 BinPy Development Team +Copyright(c) 2013 - 2016 BinPy Development Team All rights reserved.