Skip to content

Commit

Permalink
1.6.2-13: get_fit_statistic was returning NULL for slang fit statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
John C. Houck committed Dec 3, 2012
1 parent 373d016 commit ce2a776
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes.txt
Expand Up @@ -19,6 +19,7 @@ Changes since 1.6.2 (released Jan 2012)
uninitialized)
12. Fix indexing bug associated with handling ignore/notice in
change #9 above.
13. get_fit_statistic was returning NULL for slang fit statistics

Changes since 1.6.1 (released Jul 2010)
---------------------------------------
Expand Down
27 changes: 25 additions & 2 deletions src/fit-engine.c
Expand Up @@ -512,6 +512,12 @@ static int sl_report_function (Isis_Fit_Statistic_Type *s, void *pfp, double sta

/*}}}*/

static void sl_deallocate_function (Isis_Fit_Statistic_Type *s)
{
ISIS_FREE (s->symbol);
ISIS_FREE (s->option_string);
}

static Isis_Fit_Statistic_Type *init_sl_statistic (void) /*{{{*/
{
SLang_Name_Type *statistic_fun, *report_fun;
Expand Down Expand Up @@ -543,6 +549,7 @@ static Isis_Fit_Statistic_Type *init_sl_statistic (void) /*{{{*/
}

s->compute_statistic = sl_statistic_function;
s->deallocate = sl_deallocate_function;
s->report = sl_report_function;
s->sl_fun = statistic_fun;
s->sl_report = report_fun;
Expand All @@ -552,10 +559,26 @@ static Isis_Fit_Statistic_Type *init_sl_statistic (void) /*{{{*/

/*}}}*/

static int fixup_sl_statistic_name (char *name)
{
Isis_Fit_Statistic_Type *s;

if (NULL == (s = find_statistic (name)))
return -1;

if (NULL == (s->option_string = isis_make_string (name)))
return -1;

return 0;
}

void _add_slang_statistic (char *name) /*{{{*/
{
if (-1 == isis_fit_add_statistic (name, init_sl_statistic))
isis_vmesg (FAIL, I_FAILED, __FILE__, __LINE__, "adding fit statistic %s", name);
if ((-1 == isis_fit_add_statistic (name, init_sl_statistic))
|| (-1 == fixup_sl_statistic_name (name)))
{
isis_vmesg (FAIL, I_FAILED, __FILE__, __LINE__, "adding fit statistic %s", name);
}
}

/*}}}*/
Expand Down
2 changes: 1 addition & 1 deletion src/isis.h
Expand Up @@ -36,7 +36,7 @@ extern "C" {
#include <slang.h>

#define ISIS_VERSION 10602
#define ISIS_VERSION_STRING "1.6.2-12"
#define ISIS_VERSION_STRING "1.6.2-13"
#define ISIS_VERSION_PREFIX 1.6.2

#define ISIS_API_VERSION 6
Expand Down
3 changes: 3 additions & 0 deletions test/fit.sl
Expand Up @@ -164,6 +164,9 @@ define try_user_statistic () %{{{
failed ("max_like [chisqr]");

() = evalfile ("max_like.sl");
if (NULL == get_fit_statistic ())
failed ("max_like [name]");

variable max_info;
if (-1 == eval_counts(&max_info))
failed ("max_like [1]");
Expand Down

0 comments on commit ce2a776

Please sign in to comment.