baggepinnen / ControlSystemIdentification.jl

System Identification toolbox, compatible with ControlSystems.jl
https://baggepinnen.github.io/ControlSystemIdentification.jl/dev
MIT License
132 stars 13 forks source link

Fix printing of FRD #102

Closed ErikQQY closed 2 years ago

ErikQQY commented 2 years ago

The currect printing of FRD object doesn't look good, this PR add formal printing for FRD

w = exp10.(LinRange(-2, 2, 200))
r = freqresp(ssrand(1,1,3), w).parent
frd = FRD(w, r)

The printing would be like this:

Frequency(rad/s)
----------------
200-element Vector{Float64}:
   0.01
   0.010473708979594498
   0.01096985797892384
   0.011489510001873086
   0.012033778407775893
   0.012603829296797275
   0.01320088400831418
   0.013826221737646563
   ⋮
  72.32633896483533
  75.75250258771912
  79.34096665797492
  83.09941949353396
  87.03591361485165
  91.15888299750819
  95.47716114208056
 100.0

Response
--------
1×1×200 Array{ComplexF64, 3}:
[:, :, 1] =
 96.85986024447665 - 368.81990310569347im

[:, :, 2] =
 88.75566795987467 - 354.185131583798im

[:, :, 3] =
 81.28549813918279 - 339.96697827730605im

...

[:, :, 198] =
 -0.8123147236419067 - 0.020962268983231343im

[:, :, 199] =
 -0.8122410854433583 - 0.020012515911651006im

[:, :, 200] =
 -0.8121739530251701 - 0.019105934241193563im
baggepinnen commented 2 years ago

Cool, that looks nice :) Perhaps we could issue a show on an FRD object in the tests as well, preferably a very small FRD object as to not pollute the test log too much.

ErikQQY commented 2 years ago

Sorry, I am a little confused, while the return value of show is nothing, how can we add tests for show method?🤔

baggepinnen commented 2 years ago

We don't need to test that it returns something, it's enough to call the show(frd) method to see that it does not throw an exception. I usually do this by

@test_nowarn show(frd)

to test that no errors or warnings were issued

ErikQQY commented 2 years ago

Add test for FRD printing, a really small one🤣

baggepinnen commented 2 years ago

Thanks for the contribution :)