Skip to content

Commit 68b5dd1

Browse files
committed
address additional comments from roryyorke in PR #135
1 parent b697a08 commit 68b5dd1

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __conda_*.txt
99
record.txt
1010
build.log
1111
*.egg-info/
12+
.eggs/
1213
.coverage
1314
doc/_build
1415
doc/generated
@@ -18,4 +19,7 @@ examples/.ipynb_checkpoints/
1819
.project
1920
Untitled*.ipynb
2021
*.idea/
21-
.eggs
22+
23+
# Files created by or for emacs (RMM, 29 Dec 2017)
24+
*~
25+
TAGS

control/tests/xferfcn_input_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
#
3-
# xferfcn_test.py - test TransferFunction class
4-
# RMM, 30 Mar 2011 (based on TestXferFcn from v0.4a)
3+
# xferfcn_input_test.py - test inputs to TransferFunction class
4+
# jed-frey, 18 Feb 2017 (based on xferfcn_test.py)
55

66
import unittest
77
import numpy as np

control/xferfcn.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# Python 3 compatibility (needs to go here)
1111
from __future__ import print_function
1212
from __future__ import division
13-
from __future__ import absolute_import
1413

1514
"""Copyright (c) 2010 by California Institute of Technology
1615
All rights reserved.
@@ -170,13 +169,6 @@ def __init__(self, *args):
170169
if zeronum:
171170
den[i][j] = ones(1)
172171

173-
# Check for coefficients that are ints and convert to floats
174-
# TODO
175-
for k in range(den[i][j]):
176-
if (isinstance(data[i], (int, np.int))):
177-
den[i][j][k] = float(den[i][j][k])
178-
179-
180172
LTI.__init__(self, inputs, outputs, dt)
181173
self.num = num
182174
self.den = den
@@ -1338,18 +1330,18 @@ def _cleanPart(data):
13381330
13391331
Returns
13401332
-------
1341-
data: correctly formatted transfer function part.
1333+
data: list of lists of ndarrays, with int converted to float
13421334
'''
13431335
valid_types = (int, float, complex, np.number)
13441336
valid_collection = (list, tuple, ndarray)
13451337

13461338
if (isinstance(data, valid_types) or
13471339
(isinstance(data, ndarray) and data.ndim == 0)):
13481340
# Data is a scalar (including 0d ndarray)
1349-
return [[array([data])]]
1341+
data = [[array([data])]]
13501342
elif (isinstance(data, valid_collection) and
13511343
all([isinstance(d, valid_types) for d in data])):
1352-
return [[array(data]]
1344+
data = [[array(data)]]
13531345
elif (isinstance(data, (list, tuple)) and
13541346
isinstance(data[0], (list, tuple)) and
13551347
(isinstance(data[0][0], valid_collection) and
@@ -1359,10 +1351,19 @@ def _cleanPart(data):
13591351
data[j] = list(data[j])
13601352
for k in range(len(data[j])):
13611353
data[j][k] = array(data[j][k])
1362-
return data
13631354
else:
13641355
# If the user passed in anything else, then it's unclear what
13651356
# the meaning is.
13661357
raise TypeError("The numerator and denominator inputs must be \
13671358
scalars or vectors (for\nSISO), or lists of lists of vectors (for SISO or \
13681359
MIMO).")
1360+
1361+
# Check for coefficients that are ints and convert to floats
1362+
for i in range(len(data)):
1363+
for j in range(len(data[i])):
1364+
for k in range(len(data[i][j])):
1365+
if (isinstance(data[i][j][k], (int, np.int))):
1366+
data[i][j][k] = float(data[i][j][k])
1367+
1368+
return data
1369+

0 commit comments

Comments
 (0)