Commit Graph

10 Commits

Author SHA1 Message Date
Jacob Schreiber 5978c0bbdf ENH split _tree.pyx into several files 2015-09-09 11:28:24 +02:00
Arnaud Joly ce8b214154 MAINT reduce amount of boiler code using standard C operations 2014-06-19 20:13:59 +02:00
Gilles Louppe da95ad8a65 FIX: Set correct impurity values in BestFirstBuilder 2014-04-10 20:27:37 +02:00
Arnaud Joly 2c82c8adf0 FIX tons of flake8 2014-03-20 14:20:35 +01:00
Arnaud Joly abaf100a65 WIP add n_constant_features argument 2014-03-10 12:15:58 +01:00
Lars Buitinck 7fc52ffdb4 BUG fix unchecked mallocs in trees
All mallocs should be checked now. Some notes for the next person to touch
this code, or do anything with malloc in Cython code:

* with gil: raise MemoryError() didn't work as expected, as a surrounding
  nogil block catches and logs the exception, then proceeds as if nothing
  happened.
* There were several opportunities for double free in the code. This is
  handled by letting the destructor handle the freeing.
* Similarly, constructors failed to set pointers to NULL so __dealloc__
  would try to free unitialized pointers.
* Out of memory might leave trees in an inconsistent state, but will not
  cause a double free. A subsequent successful fit should produce a
  consistent state, although I didn't test this.
* Replaced a free/calloc with a realloc; realloc(NULL, n) = malloc(n).
* free(NULL) is a harmless no-op per ISO C89.

Also performed an optimization: the pre-sort splitter was using size_t for
an array of booleans. unsigned char is faster and smaller.

Finally, fixed some cosmetic issues (long lines).
2014-01-11 15:44:44 +01:00
Peter Prettenhofer dd680d6a2f malloc / realloc checks
correct rc values
2014-01-06 13:56:23 +01:00
Gilles Louppe ce0d52ea05 COSMITS + FIX to impurity_improvement 2013-11-29 14:02:21 +01:00
Gilles Louppe fbab2cd5e2 COSMIT + FIX in _utils.pyx 2013-11-29 11:15:59 +01:00
Peter Prettenhofer 635505e544 moved data structures (Stack + Heap) to _utils
use impurity_improvement for choosing best split
2013-11-22 15:33:59 +01:00