Recent

Author Topic: TFItSeries: Issues when fits are not successful  (Read 2335 times)

wp

  • Hero Member
  • *****
  • Posts: 7633
TFItSeries: Issues when fits are not successful
« on: November 21, 2012, 05:30:43 pm »
The fit series uses an internal status variable FValidFitParams to memorize whether the recent fit has been successful. This variable should be made accessible as a readonly property. Presently, the application cannot check whether the fit has been executed successfully.

If a fit fails the function EquationText (or GetFitEquationString) returns the result of the previous, successful fit. It should return an empty string instead.

Moreover, the fit curve of the old fit is not erased because the Draw procedure is simply exited. It would be better if the chart would redraw and erase the incorrect curve.

See attached demo.

P.S. I was trying to fix it myself but got stuck with the EquationText construction...
« Last Edit: November 21, 2012, 06:13:51 pm by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TFItSeries: Issues when fits are not successful
« Reply #1 on: November 22, 2012, 12:27:00 pm »
Should be fixed in r39337-39340.

Note that I have made a couple of incompatible changes:
1) Extracted equation text-related code in a separate unit. Besides slight shortening of TAFuncSeries, which is becoming too large, this code can now be unit-tested, since TAFitUtils unit does not depend on graphics.

2) ExecFit is now called lazily instead of previous eager implementation. This gives both minor optimization and more consistent code, but may require user code to manually call ExecFit in some cases. Also, FValidFitParams boolean is replaced by State enumeration to represent "unknown" validation state.

wp

  • Hero Member
  • *****
  • Posts: 7633
Re: TFItSeries: Issues when fits are not successful
« Reply #2 on: November 22, 2012, 09:49:03 pm »
Thank you. Could give a me a rough idea of when an explicit call to Execfit is needed nod?
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TFItSeries: Issues when fits are not successful
« Reply #3 on: November 23, 2012, 11:02:41 am »
Assignment to FitEquation and similar properties invalidates fit parameters.
They are recalculated on the next call to ExecFit (which is performed by Draw automatically). You can get a full list by searching for "FState := fpsUnknown;" in TAFuncSeries unit.

 

TinyPortal © 2005-2018