Menu

Problem importing library: 'module' has no attribute 'tf'

2015-10-25
2015-10-27
  • Matthew Kennedy

    Matthew Kennedy - 2015-10-25

    Hey,

    I had a question about how to get python-control library up and running. I'm a mechanical engineering student studying controls and I would love to be able to do my work in python so I don't have to buy matlab.

    Problem
    I can't get the control library to import and compile in my script but I can import the library when in terminal but certain commands don't work properly.

    import control as cnt

    sys = cnt.tf([1,5],[1,3,2,0])

    When I run python through the terminal I can import the library just fine, but the rlocus command doesn't return a plot.

    import control as cnt
    sys = cnt.tf([1,5],[1,3,2,0])
    cnt.rlocus(sys)
    (array([[ -2.00149589e+00 +0.j , -9.95995932e-01 +0.j ,
    -2.50817443e-03 +0.j ]
    ,
    [ -2.00198136e+00 +0.j , -9.94689965e-01 +0.j ,
    -3.32867365e-03 +0.j ]
    ,
    [ -2.00262363e+00 +0.j , -9.92957230e-01 +0.j ,
    -4.41914331e-03 +0.j ]
    ,
    [ -2.00347277e+00 +0.j , -9.90657610e-01 +0.j ,
    -5.86961909e-03 +0.j ]
    ,
    [ -2.00459446e+00 +0.j , -9.87604433e-01 +0.j ,
    -7.80110937e-03 +0.j ]
    ,
    [ -2.00607447e+00 +0.j , -9.83548520e-01 +0.j ,
    -1.03770058e-02 +0.j ]
    ,
    [ -2.00802439e+00 +0.j , -9.78156293e-01 +0.j ,
    -1.38193191e-02 +0.j ]
    ,
    [ -2.01058842e+00 +0.j , -9.70979274e-01 +0.j ,
    -1.84323083e-02 +0.j ]
    ,
    [ -2.01395155e+00 +0.j , -9.61410535e-01 +0.j ,
    -2.46379146e-02 +0.j ]
    ,
    [ -2.01834869e+00 +0.j , -9.48620276e-01 +0.j ,
    -3.30310380e-02 +0.j ]
    ,
    [ -2.02407432e+00 +0.j , -9.31455252e-01 +0.j ,
    -4.44704322e-02 +0.j ]
    ,
    [ -2.03149171e+00 +0.j , -9.08269091e-01 +0.j ,
    -6.02391993e-02 +0.j ]
    ,
    [ -2.04104005e+00 +0.j , -8.76602367e-01 +0.j ,
    -8.23575832e-02 +0.j ]
    ,
    [ -2.05323736e+00 +0.j , -8.32475884e-01 +0.j ,
    -1.14286760e-01 +0.j ]
    ,
    [ -2.06867685e+00 +0.j , -7.68403377e-01 +0.j ,
    -1.62919774e-01 +0.j ]
    ,
    [ -2.08801476e+00 +0.j , -6.64566411e-01 +0.j ,
    -2.47418829e-01 +0.j ]
    ,
    [ -2.11194900e+00 +0.j , -4.44025498e-01 +0.13547235j,
    -4.44025498e-01 -0.13547235j]
    ,
    [ -2.14119022e+00 +0.j , -4.29404889e-01 +0.31211473j,
    -4.29404889e-01 -0.31211473j]
    ,
    [ -2.17642905e+00 +0.j , -4.11785477e-01 +0.44494365j,
    -4.11785477e-01 -0.44494365j]
    ,
    [ -2.21830469e+00 +0.j , -3.90847657e-01 +0.57034623j,
    -3.90847657e-01 -0.57034623j]
    ,
    [ -2.26737946e+00 +0.j , -3.66310269e-01 +0.6970401j ,
    -3.66310269e-01 -0.6970401j ]
    ,
    [ -2.32412173e+00 +0.j , -3.37939137e-01 +0.82929677j,
    -3.37939137e-01 -0.82929677j]
    ,
    [ -2.38889672e+00 +0.j , -3.05551642e-01 +0.97002418j,
    -3.05551642e-01 -0.97002418j]
    ,
    [ -2.46196261e+00 +0.j , -2.69018695e-01 +1.12166375j,
    -2.69018695e-01 -1.12166375j]
    ,
    [ -2.54346804e+00 +0.j , -2.28265982e-01 +1.28655803j,
    -2.28265982e-01 -1.28655803j]
    ,
    [ -2.63344762e+00 +0.j , -1.83276188e-01 +1.46714306j,
    -1.83276188e-01 -1.46714306j]
    ,
    [ -2.73181320e+00 +0.j , -1.34093398e-01 +1.66607344j,
    -1.34093398e-01 -1.66607344j]
    ,
    [ -2.83833945e+00 +0.j , -8.08302742e-02 +1.88632145j,
    -8.08302742e-02 -1.88632145j]
    ,
    [ -2.95264400e+00 +0.j , -2.36780004e-02 +2.13126951j,
    -2.36780004e-02 -2.13126951j]
    ,
    [ -3.07416297e+00 +0.j , 3.70814855e-02 +2.40480651j,
    3.70814855e-02 -2.40480651j]
    ,
    [ -3.20212394e+00 +0.j , 1.01061968e-01 +2.71143481j,
    1.01061968e-01 -2.71143481j]
    ,
    [ -3.33551935e+00 +0.j , 1.67759674e-01 +3.05639328j,
    1.67759674e-01 -3.05639328j]
    ,
    [ -3.47308494e+00 +0.j , 2.36542469e-01 +3.44580028j,
    2.36542469e-01 -3.44580028j]
    ,
    [ -3.61328897e+00 +0.j , 3.06644486e-01 +3.88682015j,
    3.06644486e-01 -3.88682015j]
    ,
    [ -3.75433990e+00 +0.j , 3.77169948e-01 +4.38785551j,
    3.77169948e-01 -4.38785551j]
    ,
    [ -3.89422065e+00 +0.j , 4.47110326e-01 +4.95876619j,
    4.47110326e-01 -4.95876619j]
    ,
    [ -4.03075727e+00 +0.j , 5.15378635e-01 +5.61111365j,
    5.15378635e-01 -5.61111365j]
    ,
    [ -4.16172588e+00 +0.j , 5.80862938e-01 +6.35842753j,
    5.80862938e-01 -6.35842753j]
    ,
    [ -4.28499502e+00 +0.j , 6.42497508e-01 +7.21648951j,
    6.42497508e-01 -7.21648951j]
    ,
    [ -4.39868964e+00 +0.j , 6.99344821e-01 +8.20363039j,
    6.99344821e-01 -8.20363039j]
    ,
    [ -4.50135177e+00 +0.j , 7.50675883e-01 +9.34104011j,
    7.50675883e-01 -9.34104011j]
    ,
    [ -4.59206571e+00 +0.j , 7.96032856e-01+10.65309887j,
    7.96032856e-01-10.65309887j]
    ,
    [ -4.67051854e+00 +0.j , 8.35259271e-01+12.1677475j ,
    8.35259271e-01-12.1677475j ]
    ,
    [ -4.73698047e+00 +0.j , 8.68490235e-01+13.91692366j,
    8.68490235e-01-13.91692366j]
    ,
    [ -4.79221141e+00 +0.j , 8.96105703e-01+15.93709384j,
    8.96105703e-01-15.93709384j]
    ,
    [ -4.83731904e+00 +0.j , 9.18659519e-01+18.26990743j,
    9.18659519e-01-18.26990743j]
    ,
    [ -4.87360242e+00 +0.j , 9.36801210e-01+20.96299174j,
    9.36801210e-01-20.96299174j]
    ,
    [ -4.90241127e+00 +0.j , 9.51205633e-01+24.07089972j,
    9.51205633e-01-24.07089972j]
    ,
    [ -4.92503918e+00 +0.j , 9.62519588e-01+27.65621911j,
    9.62519588e-01-27.65621911j]
    ,
    [ -4.94265590e+00 +0.j , 9.71327951e-01+31.79085406j,
    9.71327951e-01-31.79085406j]
    ]), array([ 1.00000000e-03, 1.32571137e-03, 1.75751062e-03,
    2.32995181e-03, 3.08884360e-03, 4.09491506e-03,
    5.42867544e-03, 7.19685673e-03, 9.54095476e-03,
    1.26485522e-02, 1.67683294e-02, 2.22299648e-02,
    2.94705170e-02, 3.90693994e-02, 5.17947468e-02,
    6.86648845e-02, 9.10298178e-02, 1.20679264e-01,
    1.59985872e-01, 2.12095089e-01, 2.81176870e-01,
    3.72759372e-01, 4.94171336e-01, 6.55128557e-01,
    8.68511374e-01, 1.15139540e+00, 1.52641797e+00,
    2.02358965e+00, 2.68269580e+00, 3.55648031e+00,
    4.71486636e+00, 6.25055193e+00, 8.28642773e+00,
    1.09854114e+01, 1.45634848e+01, 1.93069773e+01,
    2.55954792e+01, 3.39322177e+01, 4.49843267e+01,
    5.96362332e+01, 7.90604321e+01, 1.04811313e+02,
    1.38949549e+02, 1.84206997e+02, 2.44205309e+02,
    3.23745754e+02, 4.29193426e+02, 5.68986603e+02,
    7.54312006e+02, 1.00000000e+03]
    ))

    A python application starts up but doesn't have any windows.

    I'm on Mac Yosemite, installed python-control via pip, and I've ran the setup.py test, results below:

    Test Output
    Matthews-MBP:control-0.7.0 Marek$ python setup.py test
    running test
    running egg_info
    writing requirements to control.egg-info/requires.txt
    writing control.egg-info/PKG-INFO
    writing top-level names to control.egg-info/top_level.txt
    writing dependency_links to control.egg-info/dependency_links.txt
    reading manifest file 'control.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching 'tests/*.py'
    writing manifest file 'control.egg-info/SOURCES.txt'
    running build_ext
    testSSSS1 (control.tests.bdalg_test.TestFeedback)
    State space system with state space feedback block. ... ok
    testSSSS2 (control.tests.bdalg_test.TestFeedback)
    State space system with state space feedback block, including a ... ok
    testSSScalar (control.tests.bdalg_test.TestFeedback)
    State space system with scalar feedback block. ... ok
    testSSTF (control.tests.bdalg_test.TestFeedback)
    State space system with transfer function feedback block. ... ok
    testScalarSS (control.tests.bdalg_test.TestFeedback)
    Scalar system with state space feedback block. ... ok
    testScalarScalar (control.tests.bdalg_test.TestFeedback)
    Scalar system with scalar feedback block. ... ok
    testScalarTF (control.tests.bdalg_test.TestFeedback)
    Scalar system with transfer function feedback block. ... ok
    testTFSS (control.tests.bdalg_test.TestFeedback)
    Transfer function system with state space feedback block. ... ok
    testTFScalar (control.tests.bdalg_test.TestFeedback)
    Transfer function system with scalar feedback block. ... ok
    testTFTF (control.tests.bdalg_test.TestFeedback)
    Transfer function system with transfer function feedback block. ... ok
    testConvert (control.tests.convert_test.TestConvert)
    Test state space to transfer function conversion. ... ok
    testAddition (control.tests.discrete_test.TestDiscrete) ... ok
    testCopyConstructor (control.tests.discrete_test.TestDiscrete) ... ok
    testFeedback (control.tests.discrete_test.TestDiscrete) ... ok
    testMultiplication (control.tests.discrete_test.TestDiscrete) ... ok
    testSimulation (control.tests.discrete_test.TestDiscrete) ... ok
    testSystemInitialization (control.tests.discrete_test.TestDiscrete) ... ok
    testTimebaseEqual (control.tests.discrete_test.TestDiscrete) ... ok
    test_discrete_bode (control.tests.discrete_test.TestDiscrete) ... ok
    test_sample_ss (control.tests.discrete_test.TestDiscrete) ... ok
    test_sample_system (control.tests.discrete_test.TestDiscrete) ... ok
    test_sample_tf (control.tests.discrete_test.TestDiscrete) ... ok
    test_timebase (control.tests.discrete_test.TestDiscrete) ... ok
    testisctime (control.tests.discrete_test.TestDiscrete) ... ok
    testisdtime (control.tests.discrete_test.TestDiscrete) ... ok
    testAgainstOctave (control.tests.frd_test.TestFRD) ... ok
    testAuto (control.tests.frd_test.TestFRD) ... ok
    testBadInputType (control.tests.frd_test.TestFRD)
    Give the constructor invalid input types. ... ok
    testFeedback (control.tests.frd_test.TestFRD) ... ok
    testFeedback2 (control.tests.frd_test.TestFRD) ... ok
    testInconsistentDimension (control.tests.frd_test.TestFRD) ... ok
    testMIMO (control.tests.frd_test.TestFRD) ... ok
    testMIMOMult (control.tests.frd_test.TestFRD) ... ok
    testMIMOSmooth (control.tests.frd_test.TestFRD) ... ok
    testMIMOfb (control.tests.frd_test.TestFRD) ... ok
    testMIMOfb2 (control.tests.frd_test.TestFRD) ... ok
    testNyquist (control.tests.frd_test.TestFRD) ... ok
    testOperators (control.tests.frd_test.TestFRD) ... ok
    testOperatorsTf (control.tests.frd_test.TestFRD) ... ok
    testSISOtf (control.tests.frd_test.TestFRD) ... ok
    testbdalg (control.tests.frd_test.TestFRD) ... ok
    test_phase_crossover_frequencies (control.tests.margin_test.TestMargin) ... ok
    test_stability_margins (control.tests.margin_test.TestMargin) ... ok
    test_care (control.tests.mateqn_test.TestMatrixEquations) ... ok
    test_care_g (control.tests.mateqn_test.TestMatrixEquations) ... ok
    test_dare (control.tests.mateqn_test.TestMatrixEquations) ... ok
    test_dare_g (control.tests.mateqn_test.TestMatrixEquations) ... ok
    test_dlyap (control.tests.mateqn_test.TestMatrixEquations) ... ok
    test_dlyap_g (control.tests.mateqn_test.TestMatrixEquations) ... ok
    test_dlyap_sylvester (control.tests.mateqn_test.TestMatrixEquations) ... ok
    test_lyap (control.tests.mateqn_test.TestMatrixEquations) ... ok
    test_lyap_g (control.tests.mateqn_test.TestMatrixEquations) ... ok
    test_lyap_sylvester (control.tests.mateqn_test.TestMatrixEquations) ... ok
    testBalred (control.tests.matlab_test.TestMatlab) ... ok
    testBode (control.tests.matlab_test.TestMatlab) ... ok
    testCombi01 (control.tests.matlab_test.TestMatlab) ... SKIP: need to update margin command
    testConnect (control.tests.matlab_test.TestMatlab) ... ok
    testConnect2 (control.tests.matlab_test.TestMatlab) ... ok
    testCtrb (control.tests.matlab_test.TestMatlab) ... ok
    testDamp (control.tests.matlab_test.TestMatlab) ... ok
    testDcgain (control.tests.matlab_test.TestMatlab) ... ok
    testDrss (control.tests.matlab_test.TestMatlab) ... ok
    testEvalfr (control.tests.matlab_test.TestMatlab) ... ok
    testFRD (control.tests.matlab_test.TestMatlab) ... ok
    testFeedback (control.tests.matlab_test.TestMatlab) ... ok
    testFreqresp (control.tests.matlab_test.TestMatlab) ... ok
    testGram (control.tests.matlab_test.TestMatlab) ... ok
    testHsvd (control.tests.matlab_test.TestMatlab) ... ok
    testImpulse (control.tests.matlab_test.TestMatlab) ... ok
    testInitial (control.tests.matlab_test.TestMatlab) ... ok
    testLQR (control.tests.matlab_test.TestMatlab) ... ok
    testLsim (control.tests.matlab_test.TestMatlab) ... ok
    testMIMOssdata (control.tests.matlab_test.TestMatlab) ... ok
    testMargin (control.tests.matlab_test.TestMatlab) ... ok
    testMinreal (control.tests.matlab_test.TestMatlab)
    Test a minreal model reduction ... ok
    testModred (control.tests.matlab_test.TestMatlab) ... ok
    testNichols (control.tests.matlab_test.TestMatlab) ... ok
    testNyquist (control.tests.matlab_test.TestMatlab) ... ok
    testObsv (control.tests.matlab_test.TestMatlab) ... ok
    testOpers (control.tests.matlab_test.TestMatlab) ... ok
    testPZmap (control.tests.matlab_test.TestMatlab) ... /usr/local/lib/python2.7/site-packages/numpy/ma/core.py:3895: UserWarning: Warning: converting a masked element to nan.
    warnings.warn("Warning: converting a masked element to nan.")
    ok
    testPade (control.tests.matlab_test.TestMatlab) ... ok
    testParallel (control.tests.matlab_test.TestMatlab) ... ok
    testPlace (control.tests.matlab_test.TestMatlab) ... ok
    testPoleZero (control.tests.matlab_test.TestMatlab) ... ok
    testRlocus (control.tests.matlab_test.TestMatlab) ... ok
    testRss (control.tests.matlab_test.TestMatlab) ... ok
    testSISOssdata (control.tests.matlab_test.TestMatlab) ... ok
    testSISOtfdata (control.tests.matlab_test.TestMatlab) ... ok
    testSS2cont (control.tests.matlab_test.TestMatlab) ... ok
    testSeries (control.tests.matlab_test.TestMatlab) ... ok
    testStep (control.tests.matlab_test.TestMatlab) ... ok
    testUnwrap (control.tests.matlab_test.TestMatlab) ... ok
    control.tests.matlab_test.test_suite ... ok
    testMinrealBrute (control.tests.minreal_test.TestMinreal) ... ok
    testMinrealSS (control.tests.minreal_test.TestMinreal)
    Test a minreal model reduction ... ok
    testMinrealtf (control.tests.minreal_test.TestMinreal)
    Try the minreal function, and also test easy entry by creation ... ok
    testBalredTruncate (control.tests.modelsimp_test.TestModelsimp) ... ok
    testHSVD (control.tests.modelsimp_test.TestModelsimp) ... ok
    testMarkov (control.tests.modelsimp_test.TestModelsimp) ... ok
    testModredMatchDC (control.tests.modelsimp_test.TestModelsimp) ... ok
    testModredTruncate (control.tests.modelsimp_test.TestModelsimp) ... ok
    testNgrid (control.tests.nichols_test.TestStateSpace)
    Generate a Nichols plot. ... ok
    testNicholsPlain (control.tests.nichols_test.TestStateSpace)
    Generate a Nichols plot. ... ok
    testInvPendAuto (control.tests.phaseplot_test.TestPhasePlot) ... ok
    testInvPendLogtime (control.tests.phaseplot_test.TestPhasePlot) ... ok
    testInvPendNoSims (control.tests.phaseplot_test.TestPhasePlot) ... ok
    testInvPendSims (control.tests.phaseplot_test.TestPhasePlot) ... ok
    testInvPendTimePoints (control.tests.phaseplot_test.TestPhasePlot) ... ok
    testOscillatorParams (control.tests.phaseplot_test.TestPhasePlot) ... ok
    testRootLocus (control.tests.rlocus_test.TestRootLocus)
    Basic root locus plot ... ok
    test_without_gains (control.tests.rlocus_test.TestRootLocus) ... ok
    control.tests.rlocus_test.test_suite ... ok
    testFreqResp (control.tests.slycot_convert_test.TestSlycot)
    Compare the bode reponses of the SS systems and TF systems to the original SS ... ok
    testTF (control.tests.slycot_convert_test.TestSlycot)
    Directly tests the functions tb04ad and td04ad through direct ... ok
    testAcker (control.tests.statefbk_test.TestStatefbk) ... ok
    testCtrbMIMO (control.tests.statefbk_test.TestStatefbk) ... ok
    testCtrbObsvDuality (control.tests.statefbk_test.TestStatefbk) ... ok
    testCtrbSISO (control.tests.statefbk_test.TestStatefbk) ... ok
    testGramWc (control.tests.statefbk_test.TestStatefbk) ... ok
    testGramWo (control.tests.statefbk_test.TestStatefbk) ... ok
    testGramWo2 (control.tests.statefbk_test.TestStatefbk) ... ok
    testGramsys (control.tests.statefbk_test.TestStatefbk) ... ok
    testObsvMIMO (control.tests.statefbk_test.TestStatefbk) ... ok
    testObsvSISO (control.tests.statefbk_test.TestStatefbk) ... ok
    test_LQR_3args (control.tests.statefbk_test.TestStatefbk) ... ok
    test_LQR_integrator (control.tests.statefbk_test.TestStatefbk) ... ok
    control.tests.statefbk_test.test_suite ... ok
    testPole (control.tests.statesp_test.TestDrss)
    Test that the poles of drss outputs have less than unit magnitude. ... ok
    testShape (control.tests.statesp_test.TestDrss)
    Test that drss outputs have the right state, input, and output ... ok
    testPole (control.tests.statesp_test.TestRss)
    Test that the poles of rss outputs have a negative real part. ... ok
    testShape (control.tests.statesp_test.TestRss)
    Test that rss outputs have the right state, input, and output ... ok
    testAdd (control.tests.statesp_test.TestStateSpace)
    Add two MIMO systems. ... ok
    testAppendSS (control.tests.statesp_test.TestStateSpace)
    Test appending two state-space systems ... ok
    testAppendTF (control.tests.statesp_test.TestStateSpace)
    Test appending a state-space system with a tf ... ok
    testArrayAccessSS (control.tests.statesp_test.TestStateSpace) ... ok
    testEvalFr (control.tests.statesp_test.TestStateSpace)
    Evaluate the frequency response at one frequency. ... ok
    testFreqResp (control.tests.statesp_test.TestStateSpace)
    Evaluate the frequency response at multiple frequencies. ... ok
    testMinreal (control.tests.statesp_test.TestStateSpace)
    Test a minreal model reduction ... ok
    testMul (control.tests.statesp_test.TestStateSpace)
    Multiply two MIMO systems. ... ok
    testPole (control.tests.statesp_test.TestStateSpace)
    Evaluate the poles of a MIMO system. ... ok
    testSub (control.tests.statesp_test.TestStateSpace)
    Subtract two MIMO systems. ... ok
    testZero (control.tests.statesp_test.TestStateSpace)
    Evaluate the zeros of a SISO system. ... ok
    test_check_convert_shape (control.tests.test_control_matlab.TestControlMatlab) ... SKIP: skipping test_check_convert_shape, need to update test
    test_convert_MIMO_to_SISO (control.tests.test_control_matlab.TestControlMatlab)
    Convert mimo to siso systems ... ok
    test_dcgain (control.tests.test_control_matlab.TestControlMatlab)
    Test function dcgain with different systems ... ok
    test_dcgain_2 (control.tests.test_control_matlab.TestControlMatlab)
    Test function dcgain with different systems ... ok
    test_impulse (control.tests.test_control_matlab.TestControlMatlab) ... ok
    test_initial (control.tests.test_control_matlab.TestControlMatlab) ... ok
    test_lsim (control.tests.test_control_matlab.TestControlMatlab) ... SKIP: skipping test_lsim, need to update test
    test_step (control.tests.test_control_matlab.TestControlMatlab)
    Test function step. ... ok
    test_forced_response (control.tests.timeresp_test.TestTimeresp) ... ok
    test_impulse_response (control.tests.timeresp_test.TestTimeresp) ... ok
    test_initial_response (control.tests.timeresp_test.TestTimeresp) ... ok
    test_initial_response_no_trim (control.tests.timeresp_test.TestTimeresp) ... ok
    test_lsim_double_integrator (control.tests.timeresp_test.TestTimeresp) ... ok
    test_step_response (control.tests.timeresp_test.TestTimeresp) ... ok
    testAddInconsistentDimension (control.tests.xferfcn_test.TestXferFcn)
    Add two transfer function matrices of different sizes. ... ok
    testAddMIMO (control.tests.xferfcn_test.TestXferFcn)
    Add two MIMO systems. ... ok
    testAddSISO (control.tests.xferfcn_test.TestXferFcn)
    Add two SISO systems. ... ok
    testAddScalar (control.tests.xferfcn_test.TestXferFcn)
    Add two direct feedthrough systems. ... ok
    testBadInputType (control.tests.xferfcn_test.TestXferFcn)
    Give the constructor invalid input types. ... ok
    testConvertToTransferFunction (control.tests.xferfcn_test.TestXferFcn)
    Test for correct state space to transfer function conversion. ... ok
    testDivSISO (control.tests.xferfcn_test.TestXferFcn)
    Divide two SISO systems. ... ok
    testDivScalar (control.tests.xferfcn_test.TestXferFcn)
    Divide two direct feedthrough systems. ... ok
    testEvalFrMIMO (control.tests.xferfcn_test.TestXferFcn)
    Evaluate the frequency response of a MIMO system at one frequency. ... ok
    testEvalFrSISO (control.tests.xferfcn_test.TestXferFcn)
    Evaluate the frequency response of a SISO system at one frequency. ... ok
    testFeedbackSISO (control.tests.xferfcn_test.TestXferFcn)
    Test for correct SISO transfer function feedback. ... ok
    testFreqRespMIMO (control.tests.xferfcn_test.TestXferFcn)
    Evaluate the magnitude and phase of a MIMO system at multiple ... SKIP: skipping, known issue with Python 3
    testFreqRespSISO (control.tests.xferfcn_test.TestXferFcn)
    Evaluate the magnitude and phase of a SISO system at multiple ... ok
    testInconsistentColumns (control.tests.xferfcn_test.TestXferFcn)
    Give the constructor inputs that do not have the same number of ... ok
    testInconsistentDimension (control.tests.xferfcn_test.TestXferFcn)
    Give the constructor a numerator and denominator of different ... ok
    testMIMO (control.tests.xferfcn_test.TestXferFcn)
    Test conversion of a single input, two-output state-space ... ok
    testMatrixMult (control.tests.xferfcn_test.TestXferFcn)
    MIMO transfer functions should be multiplyable by constant ... ok
    testMinreal (control.tests.xferfcn_test.TestXferFcn)
    Try the minreal function, and also test easy entry by creation ... ok
    testMinreal2 (control.tests.xferfcn_test.TestXferFcn)
    This one gave a problem, due to poly([]) giving simply 1 ... ok
    testMulInconsistentDimension (control.tests.xferfcn_test.TestXferFcn)
    Multiply two transfer function matrices of incompatible sizes. ... ok
    testMulMIMO (control.tests.xferfcn_test.TestXferFcn)
    Multiply two MIMO systems. ... ok
    testMulSISO (control.tests.xferfcn_test.TestXferFcn)
    Multiply two SISO systems. ... ok
    testMulScalar (control.tests.xferfcn_test.TestXferFcn)
    Multiply two direct feedthrough systems. ... ok
    testNegMIMO (control.tests.xferfcn_test.TestXferFcn)
    Negate a MIMO system. ... ok
    testNegSISO (control.tests.xferfcn_test.TestXferFcn)
    Negate a SISO system. ... ok
    testNegScalar (control.tests.xferfcn_test.TestXferFcn)
    Negate a direct feedthrough system. ... SKIP: skipping, known issue with Python 3
    testPoleMIMO (control.tests.xferfcn_test.TestXferFcn)
    Test for correct MIMO poles. ... ok
    testSubMIMO (control.tests.xferfcn_test.TestXferFcn)
    Add two MIMO systems. ... ok
    testSubSISO (control.tests.xferfcn_test.TestXferFcn)
    Add two SISO systems. ... ok
    testSubScalar (control.tests.xferfcn_test.TestXferFcn)
    Add two direct feedthrough systems. ... ok
    testTruncateCoeff1 (control.tests.xferfcn_test.TestXferFcn)
    Remove extraneous zeros in polynomial representations. ... ok
    testTruncateCoeff2 (control.tests.xferfcn_test.TestXferFcn)
    Remove extraneous zeros in polynomial representations. ... ok
    testZeroDenominator (control.tests.xferfcn_test.TestXferFcn)
    Give the constructor a transfer function with a zero denominator. ... ok


    Ran 190 tests in 5.609s

    OK (skipped=5)

     
    • Scott C. Livingston

      On 25/10/15 09:42, Matthew Kennedy wrote:

      Problem
      I can't get the control library to import and compile in my script

      Could you send the error message that is printed when you attempt to run
      your script?

      ~Scott

       
    • Scott C. Livingston

      On 25/10/15 09:42, Matthew Kennedy wrote:

      Hey,

      I had a question about how to get python-control library up and running. I'm a mechanical engineering student studying controls and I would love to be able to do my work in python so I don't have to buy matlab.

      Problem
      I can't get the control library to import and compile in my script but I can import the library when in terminal but certain commands don't work properly.

      import control as cnt

      sys = cnt.tf([1,5],[1,3,2,0])

      When I run python through the terminal I can import the library just fine, but the rlocus command doesn't return a plot.

      import control as cnt
      sys = cnt.tf([1,5],[1,3,2,0])
      cnt.rlocus(sys)

      Try adding

      import matplotlib.pyplot as plt
      plt.show()
      

      after cnt.rlocus(sys).

      ~Scott

       
  • Richard Murray

    Richard Murray - 2015-10-25

    Not sure why things are not working in the script. Is the python-control package installed in the system directory (this would be the default, but usually requires root priviledge) or in your user directory? Perhaps there is something in that path that works differently in command line versus interactive mode?

    In terms of running things interactively, you need to run python in a way that supports graphical output. The easiest way to do that is to use 'ipython -pylab' rather than just 'python'. ipython is an interactive version of python and the -pylab option tells it to load up the right graphics packages (mainly matplotlib, I think). I ran the commands you listed and got the attached (graphical) output.

     

    Last edit: Richard Murray 2015-10-25
  • Matthew Kennedy

    Matthew Kennedy - 2015-10-27

    Thanks for the response!

    Using Ipython I am able to generate the Root locus plots. Yay!

    Found out what my issue was: The filename I used for testing out the library was titled 'control.py'. so "import control as cnt" was simply importing the file into itself...

    The script will compile now but won't display a graph but that shouldn't be to hard to figure out.

    Thanks again for your response and for writing this sweet library.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.