Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
50a60b0
feat: updating construct.c to current R state
pjaselin Jun 19, 2025
9f86c63
feat: updating contin.c to current R state
pjaselin Jun 19, 2025
89e6ee9
feat: updating defns.h to current R state
pjaselin Jun 19, 2025
a99c872
feat: updating discr.c to current R state
pjaselin Jun 19, 2025
95c61d1
feat: updating formrules.c to current R state
pjaselin Jun 19, 2025
29b0899
feat: updating formtree.c to current R state
pjaselin Jun 19, 2025
e266dff
feat: updating getdata.c to current R state
pjaselin Jun 19, 2025
f027a0d
feat: updating getnames.c to current R state
pjaselin Jun 19, 2025
809c5bb
feat: updating global.c to current R state
pjaselin Jun 19, 2025
f98ed5d
feat: updating implicitatt.c to current R state
pjaselin Jun 19, 2025
d13b7da
feat: updating instance.c to current R state
pjaselin Jun 20, 2025
498ca1c
feat: updating modelfiles.c to current R state
pjaselin Jun 20, 2025
c6f915c
feat: updating predict.c to current R state
pjaselin Jun 20, 2025
b74f8f4
feat: updating remaining true/false values to bintrue/binfalse
pjaselin Jun 20, 2025
81dbc98
feat: bringing C code up to R library state for size variable changes
pjaselin Jun 20, 2025
8d2887b
feat: updating utility.c to current R state
pjaselin Jun 20, 2025
18cfa32
Merge branch 'main' into fix/osx_incompatibility
pjaselin Nov 9, 2025
a59ac00
chore: update uv command to mypy hok
pjaselin Nov 9, 2025
b9fd24c
Merge branch 'main' into fix/osx_incompatibility
pjaselin Nov 28, 2025
b7e5146
feat: copied c/h files from R cubist library
pjaselin Nov 28, 2025
a01e293
feat: copied c/h files from R cubist library
pjaselin Nov 28, 2025
049f718
feat: copied c/h files from R cubist library
pjaselin Nov 28, 2025
5c96e48
feat: copied c/h files from R cubist library
pjaselin Nov 28, 2025
2c95fba
feat: copied c/h files from R cubist library
pjaselin Nov 28, 2025
d0301e7
feat: copied c/h files from R cubist library
pjaselin Nov 28, 2025
15495f1
feat: copied c/h files from R cubist library
pjaselin Nov 28, 2025
012d092
feat: copied c/h files from R cubist library
pjaselin Nov 28, 2025
0b1508e
feat: restoring runif function
pjaselin Nov 28, 2025
b6b1e24
feat: restoring runif function
pjaselin Nov 28, 2025
977715b
feat: restoring runif function
pjaselin Nov 28, 2025
f7ad1b7
feat: restoring runif function
pjaselin Nov 28, 2025
b56484a
feat: restoring runif function
pjaselin Nov 28, 2025
36f3fc5
feat: restoring runif function
pjaselin Nov 28, 2025
cb30f51
feat: restoring runif function
pjaselin Nov 28, 2025
65ee954
feat: restoring runif function
pjaselin Nov 28, 2025
21cb726
feat: restoring runif function
pjaselin Nov 28, 2025
ff6b54c
Merge branch 'main' into fix/osx_incompatibility
pjaselin Jan 17, 2026
c8c4033
feat: add cv back
pjaselin Jan 31, 2026
38f0c7c
feat: add cv back
pjaselin Jan 31, 2026
2651182
feat: add cv back
pjaselin Jan 31, 2026
b5262ce
feat: add cv back
pjaselin Jan 31, 2026
1ceb871
feat: add cv back
pjaselin Jan 31, 2026
aaa53b8
feat: add cv back
pjaselin Jan 31, 2026
cbb1d69
feat: add cv back
pjaselin Jan 31, 2026
2de09f1
feat: add cv back
pjaselin Jan 31, 2026
ddce4cd
feat: add cv back
pjaselin Jan 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
include README.md
include requirements.txt
include setup.py
include pyproject.toml
include cubist/src/*
Expand Down
14 changes: 8 additions & 6 deletions cubist/src/construct.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ RRuleSet ConstructRuleSet(int ModelNo)
/* ---------------- */
{
RRuleSet RS;
char Msg[20];
size_t size = 20;
char Msg[size];
CaseNo i;
RuleNo r;
float TempMTSize;
Expand Down Expand Up @@ -227,9 +228,9 @@ RRuleSet ConstructRuleSet(int ModelNo)
ForEach(r, 1, RS->SNRules) { RS->SRule[r]->MNo = ModelNo; }

if (MEMBERS > 1) {
sprintf(Msg, "Model %d:", ModelNo + 1);
snprintf(Msg, size, "Model %d:", ModelNo + 1);
} else {
sprintf(Msg, "Model:");
snprintf(Msg, size, "Model:");
}

PrintRules(RS, Msg);
Expand Down Expand Up @@ -370,7 +371,8 @@ void AttributeUsage(void)
int m;
RuleNo r;
Attribute Att, BestAtt;
char U1[5], U2[5];
size_t size = 5;
char U1[size], U2[size];

/* Initialise counts */

Expand Down Expand Up @@ -406,8 +408,8 @@ void AttributeUsage(void)
if (!BestAtt)
break;

sprintf(U1, "%3.0f%%", rint((100.0 * SumCond[BestAtt]) / SumCases));
sprintf(U2, "%3.0f%%", rint((100.0 * SumModel[BestAtt]) / SumCases));
snprintf(U1, size, "%3.0f%%", rint((100.0 * SumCond[BestAtt]) / SumCases));
snprintf(U2, size, "%3.0f%%", rint((100.0 * SumModel[BestAtt]) / SumCases));

fprintf(Of, "\t %4s %4s %s\n",
(SumCond[BestAtt] >= 0.01 * SumCases ? U1 : " "),
Expand Down
4 changes: 2 additions & 2 deletions cubist/src/contin.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* Copyright 2010 Rulequest Research Pty Ltd. */
/* */
/* This file is part of Cubist GPL Edition, a single-threaded version */
/* of Cubist release 2.07. */
/* of Cubist release 2.07. */
/* */
/* Cubist GPL Edition is free software: you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License as */
Expand Down Expand Up @@ -285,4 +285,4 @@ ContValue GreatestValueBelow(ContValue Th)
}

return SRec[Low].V;
}
}
11 changes: 3 additions & 8 deletions cubist/src/defns.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,6 @@ typedef struct _elt_rec {
/* */
/*************************************************************************/

/* for R c functions */

void GetRNGstate(void);
void PutRNGstate(void);

/* cubist.c */

int Xmain(int, char *[]);
Expand Down Expand Up @@ -574,7 +569,7 @@ void SmoothModels(Tree T, Tree Parent, CaseNo Fp, CaseNo Lp);
double ErrVariance(double *Model, CaseNo Fp, CaseNo Lp, double *Err);
double Smooth(double PVal, int PCases, double LVal, int LCases);
void FindErrors(Tree T, CaseNo Fp, CaseNo Lp);
void CValToStr(ContValue CV, Attribute Att, String DS);
void CValToStr(ContValue CV, Attribute Att, String DS, size_t DS_size);
Boolean FindWeakestSubtree(Tree T);
float TreeValue(Tree T, DataRec Case);
float MedianResid(CaseNo Fp, CaseNo Lp, double Want);
Expand Down Expand Up @@ -619,9 +614,9 @@ int Denominator(ContValue Val);
int FracBase(Attribute Att);
int GetInt(String S, int N);
int DateToDay(String DS);
void DayToDate(int DI, String Date);
void DayToDate(int DI, String Date, size_t DT_size);
int TimeToSecs(String TS);
void SecsToTime(int Secs, String Time);
void SecsToTime(int Secs, String Time, size_t DT_size);
void SetTSBase(int y);
int TStampToMins(String TS);
void Cleanup(void);
Expand Down
2 changes: 1 addition & 1 deletion cubist/src/discr.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,4 @@ void DiscreteTest(Tree Node, Attribute Att, Set *Subset)
CopyBits(Bytes, Subset[S], Node->Subset[S]);
}
}
}
}
2 changes: 1 addition & 1 deletion cubist/src/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ extern Boolean LOCK;
extern CaseCount MINITEMS;
extern int MAXRULES;

extern float EXTRAP;
extern float EXTRAP;
2 changes: 1 addition & 1 deletion cubist/src/formrules.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,4 +641,4 @@ void FreeFormRuleData(void)
Succ = Nil;
Free(CPredVal);
CPredVal = Nil;
}
}
2 changes: 1 addition & 1 deletion cubist/src/formtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,4 +574,4 @@ void FindModelAtts(double *Model)
GEnv.ModelAtt[++GEnv.NModelAtt] = Att;
}
}
}
}
11 changes: 4 additions & 7 deletions cubist/src/getdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

#include "redefine.h"
#include "transform.h"
// #include "nmath.h"
//#include <Rmath.h>

float runif( float min, float max )
{
Expand All @@ -50,9 +48,7 @@ float runif( float min, float max )
#define AltRandom my_rand()
static double my_rand(void) {
double dval;
// GetRNGstate();
dval = runif(0, 1);
// PutRNGstate();
return dval;
}

Expand Down Expand Up @@ -83,7 +79,8 @@ void GetData(FILE *Df, Boolean Train, Boolean AllowUnknownTarget)
Boolean AnyUnknown = binfalse, FirstIgnore = bintrue, *AttMsg;
Attribute Att;
ContValue Val, Range;
char CVS[20];
size_t size = 20;
char CVS[size];
CaseCount *Freq; /* discrete value frequencies */
CaseNo Count, WantTrain, LeftTrain, WantTest, LeftTest;
Boolean SelectTrain;
Expand Down Expand Up @@ -267,7 +264,7 @@ void GetData(FILE *Df, Boolean Train, Boolean AllowUnknownTarget)
if (Discrete(Att)) {
fprintf(Of, "`%s'\n", AttValName[Att][Modal[Att]]);
} else {
CValToStr(AttMean[Att], Att, CVS);
CValToStr(AttMean[Att], Att, CVS, size);
fprintf(Of, "%s\n", CVS);
}
}
Expand Down Expand Up @@ -600,4 +597,4 @@ void FindLimits(Attribute Att, ContValue *Min, ContValue *Max)
if (Val < *Min)
*Min = Val;
}
}
}
2 changes: 1 addition & 1 deletion cubist/src/getnames.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,4 @@ int InChar(FILE *f)
}

return (int)*LBp++;
}
}
2 changes: 1 addition & 1 deletion cubist/src/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ Boolean LOCK = binfalse; /* bintrue if sample locked */
CaseCount MINITEMS; /* min rule coverage */
int MAXRULES = 100; /* max number of rules */

float EXTRAP = 0.1; /* allowed extrapolation from models */
float EXTRAP = 0.1; /* allowed extrapolation from models */
2 changes: 1 addition & 1 deletion cubist/src/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,4 @@ char *ht_getstr(void *ht, const char *key, char *defval, char *errval) {
}

return (char *)entry->value;
}
}
2 changes: 1 addition & 1 deletion cubist/src/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ extern void *ht_getvoid(void *ht, const char *key, void *defval, void *errval);
// extern int ht_getint(void *ht, const char *key, int defval, int errval);
extern char *ht_getstr(void *ht, const char *key, char *defval, char *errval);

#endif
#endif
54 changes: 28 additions & 26 deletions cubist/src/implicitatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,85 +597,87 @@ void DefSyntaxError(String Msg)
void DefSemanticsError(int Fi, String Msg, int OpCode)
/* ----------------- */
{
char Exp[1000], XMsg[1008], Op[1000];
size_t size = 1000;
size_t size_x = 1008;
char Exp[size], XMsg[size_x], Op[size];

if (!PreviousError) {
/* Abbreviate the input if necessary */

if (BN - Fi > 23) {
sprintf(Exp, "%.10s...%.10s", Buff + Fi, Buff + BN - 10);
snprintf(Exp, size, "%.10s...%.10s", Buff + Fi, Buff + BN - 10);
} else {
sprintf(Exp, "%.*s", BN - Fi, Buff + Fi);
snprintf(Exp, size, "%.*s", BN - Fi, Buff + Fi);
}

switch (OpCode) {
case OP_AND:
sprintf(Op, "%s", "and");
snprintf(Op, size, "%s", "and");
break;
case OP_OR:
sprintf(Op, "%s", "or");
snprintf(Op, size, "%s", "or");
break;
case OP_SEQ:
case OP_EQ:
sprintf(Op, "%s", "=");
snprintf(Op, size, "%s", "=");
break;
case OP_SNE:
case OP_NE:
sprintf(Op, "%s", "<>");
snprintf(Op, size, "%s", "<>");
break;
case OP_GT:
sprintf(Op, "%s", ">");
snprintf(Op, size, "%s", ">");
break;
case OP_GE:
sprintf(Op, "%s", ">=");
snprintf(Op, size, "%s", ">=");
break;
case OP_LT:
sprintf(Op, "%s", "<");
snprintf(Op, size, "%s", "<");
break;
case OP_LE:
sprintf(Op, "%s", "<=");
snprintf(Op, size, "%s", "<=");
break;
case OP_PLUS:
sprintf(Op, "%s", "+");
snprintf(Op, size, "%s", "+");
break;
case OP_MINUS:
sprintf(Op, "%s", "-");
snprintf(Op, size, "%s", "-");
break;
case OP_UMINUS:
sprintf(Op, "%s", "unary -");
snprintf(Op, size, "%s", "unary -");
break;
case OP_MULT:
sprintf(Op, "%s", "*");
snprintf(Op, size, "%s", "*");
break;
case OP_DIV:
sprintf(Op, "%s", "/");
snprintf(Op, size, "%s", "/");
break;
case OP_MOD:
sprintf(Op, "%s", "%");
snprintf(Op, size, "%s", "%");
break;
case OP_POW:
sprintf(Op, "%s", "^");
snprintf(Op, size, "%s", "^");
break;
case OP_SIN:
sprintf(Op, "%s", "sin");
snprintf(Op, size, "%s", "sin");
break;
case OP_COS:
sprintf(Op, "%s", "cos");
snprintf(Op, size, "%s", "cos");
break;
case OP_TAN:
sprintf(Op, "%s", "tan");
snprintf(Op, size, "%s", "tan");
break;
case OP_LOG:
sprintf(Op, "%s", "log");
snprintf(Op, size, "%s", "log");
break;
case OP_EXP:
sprintf(Op, "%s", "exp");
snprintf(Op, size, "%s", "exp");
break;
case OP_INT:
sprintf(Op, "%s", "int");
snprintf(Op, size, "%s", "int");
}

sprintf(XMsg, "%s with '%s'", Msg, Op);
snprintf(XMsg, size_x, "%s with '%s'", Msg, Op);
Error(BADDEF2, Exp, XMsg);
PreviousError = bintrue;
}
Expand Down Expand Up @@ -1035,4 +1037,4 @@ AttValue EvaluateDef(Definition D, DataRec Case)
return ReturnVal;
}
}
}
}
2 changes: 1 addition & 1 deletion cubist/src/instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,4 +769,4 @@ void FreeInstances(void)
FreeIndex(KDTree);
KDTree = Nil;
}
}
}
3 changes: 1 addition & 2 deletions cubist/src/modelfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ void WriteFilePrefix(String Extension)
void ReadFilePrefix(String Extension)
/* -------------- */
{

if (!(Mf = GetFile(Extension, "r")))
Error(NOFILE, Fn, "");

Expand Down Expand Up @@ -758,4 +757,4 @@ Set MakeSubset(Attribute Att)
}

return S;
}
}
2 changes: 1 addition & 1 deletion cubist/src/predict.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ void FindPredictedValues(RRuleSet *Cttee, CaseNo Fp, CaseNo Lp)
PredVal(Case[i]) = (USEINSTANCES ? NNEstimate(Cttee, Case[i])
: PredictValue(Cttee, Case[i]));
}
}
}
2 changes: 1 addition & 1 deletion cubist/src/prunetree.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,4 @@ float MedianResid(CaseNo Fp, CaseNo Lp, double Want)
}

return GEnv.Resid[Fp];
}
}
4 changes: 2 additions & 2 deletions cubist/src/rcubist.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int cubistmain(void)
if (!(F = GetFile(".data", "r")))
Error(NOFILE, "", "");
GetData(F, bintrue, binfalse);
fprintf(Of, TX_ReadData(MaxCase + 1, MaxAtt));
fprintf(Of, TX_ReadData(MaxCase + 1, MaxAtt, FileStem));

if (XVAL && (F = GetFile(".test", "r"))) {
SaveMaxCase = MaxCase;
Expand Down Expand Up @@ -129,4 +129,4 @@ int cubistmain(void)
fprintf(Of, T_Time, ExecTime() - StartTime);

return 0;
}
}
Loading
Loading