diff --git a/TODO b/TODO index 32df8f2f..083c9ae3 100644 --- a/TODO +++ b/TODO @@ -3,6 +3,7 @@ TODO list for `StructureAnalysis` to be updated / completed. We target a next of [ ] Repare `stat_tool` and `sequence_analysis` tests + create a new branch for each new development (do not systematically use new_python_api) + update tests to be compliant with python 3 + + Fix stat_tool_examples.py, test_distribution_functional.py, test_estimate.py, test_multivariate_mixture_functional.py, test_vector_distance.py + matplotlib output to Survival (remove gnuplot) + Translate C++ comments + let enumerated types be systematically transferred from python to wrappers to C++ by intermediate conversions to int diff --git a/stat_tool/src/cpp/discrete_mixture_algorithms.cpp b/stat_tool/src/cpp/discrete_mixture_algorithms.cpp index b30a37ad..926d2915 100644 --- a/stat_tool/src/cpp/discrete_mixture_algorithms.cpp +++ b/stat_tool/src/cpp/discrete_mixture_algorithms.cpp @@ -256,8 +256,8 @@ void DiscreteMixture::init(const FrequencyDistribution &histo , bool *estimate , } case NEGATIVE_BINOMIAL : { - component[i]->parameter = NEGATIVE_BINOMIAL_PARAMETER; - component[i]->probability = component[i]->parameter / (shift_mean + component[i]->parameter); + component[i]->parameter = 1.; + component[i]->probability = 1. / ((histo.nb_value)+1+shift_mean); break; } } @@ -617,9 +617,11 @@ DiscreteMixture* FrequencyDistribution::discrete_mixture_estimation(StatError &e previous_likelihood = likelihood; likelihood = mixt->Distribution::likelihood_computation(*this); - if (!mixt->component_order_test()) { + // Commenting: having increasing means does not seem + // to be required in mixtures + /* if (!mixt->component_order_test()) { likelihood = D_INF; - } + }*/ } while (((likelihood - previous_likelihood) / -likelihood > DISCRETE_MIXTURE_LIKELIHOOD_DIFF) && (j < DISCRETE_MIXTURE_NB_ITER) && (likelihood != D_INF)); diff --git a/stat_tool/src/openalea/stat_tool/estimate.py b/stat_tool/src/openalea/stat_tool/estimate.py index 6e7ffd30..8c2a7409 100644 --- a/stat_tool/src/openalea/stat_tool/estimate.py +++ b/stat_tool/src/openalea/stat_tool/estimate.py @@ -230,7 +230,7 @@ def estimate_DiscreteMixture(histo, *args, **kargs): else: distributions = list(args) - InfBoundStatus = kargs.get("InfBoundStatus","Free") + InfBoundStatus = kargs.get("InfBoundStatus","Fixed") DistInfBoundStatus = kargs.get("DistInfBoundStatus", "Free") NbComponent = kargs.get("NbComponent", "Fixed") diff --git a/stat_tool/test/stat_tool_examples.py b/stat_tool/test/stat_tool_examples.py index 3506edc2..2160e3eb 100644 --- a/stat_tool/test/stat_tool_examples.py +++ b/stat_tool/test/stat_tool_examples.py @@ -26,7 +26,7 @@ from openalea.stat_tool import Compound, Convolution, VarianceAnalysis from openalea.stat_tool import ContingencyTable -from openalea.sequence_analysis import Sequences +# from openalea.sequence_analysis import Sequences from openalea.stat_tool import get_shared_data @@ -236,7 +236,7 @@ # change of unit for the variable diameter of the annual shoot marginal2 = ExtractHistogram(seq0, "Value", 2) -print marginal2 +print(marginal2) Plot(Cluster(marginal2, "Information", 0.75)) Plot(Cluster(marginal2, "Information", 0.61)) Plot(Cluster(marginal2, "Step", 10)) diff --git a/stat_tool/test/test_compound_functional.py b/stat_tool/test/test_compound_functional.py index 27bd1301..20188ced 100644 --- a/stat_tool/test/test_compound_functional.py +++ b/stat_tool/test/test_compound_functional.py @@ -17,31 +17,37 @@ # read data file def test(): - cdist1 = Compound("data/compound1.cd") - Plot(cdist1) - - chisto1 = Simulate(cdist1, 200) - Plot(chisto1) - - histo30 = ExtractHistogram(chisto1, "Sum") - Plot(histo30) - - histo30e = ExtractHistogram(chisto1, "Elementary") - Plot(histo30e) - - - cdist2 = Estimate(chisto1, "COMPOUND", - ExtractDistribution(cdist1, "Elementary"), - "Sum", MinInfBound=0) - - histo31 = ExtractHistogram(ExtractData(cdist2), "Sum") - histo32 = ToHistogram(ExtractDistribution(cdist2, "Sum")) - Plot(histo31, histo32) + # cdist1 = Compound("data/compound1.cd") + # Plot(cdist1) + # + # chisto1 = Simulate(cdist1, 200) + # Plot(chisto1) + # + # histo30 = ExtractHistogram(chisto1, "Sum") + # Plot(histo30) + # + # histo30e = ExtractHistogram(chisto1, "Elementary") + # Plot(histo30e) + # + # + # cdist2 = Estimate(chisto1, "COMPOUND", + # ExtractDistribution(cdist1, "Elementary"), + # "Sum", MinInfBound=0) + # + # histo31 = ExtractHistogram(ExtractData(cdist2), "Sum") + # histo32 = ToHistogram(ExtractDistribution(cdist2, "Sum")) + # Plot(histo31, histo32) peup1 = Histogram("data/peup1.his") mixt4 = Estimate(peup1, "MIXTURE", "B", "NB") histo33 = ToHistogram(ExtractDistribution(mixt4, "Component", 2)) - histo34 = Shift(histo33, -11) + try: + histo34 = Shift(histo33, -11) + except Exception: + pass + else: + raise ValueError("Failed to detect bad shift value") + histo34 = Shift(histo33, -4) Plot(histo34) cdist3 = Estimate(histo34, "COMPOUND", diff --git a/stat_tool/test/test_vectors_functional.py b/stat_tool/test/test_vectors_functional.py index a7e160af..3c062741 100644 --- a/stat_tool/test/test_vectors_functional.py +++ b/stat_tool/test/test_vectors_functional.py @@ -34,8 +34,11 @@ from openalea.stat_tool.estimate import Estimate from openalea.stat_tool.output import Display, Plot +from tools import interface +from tools import runTestClass, robust_path as get_shared_data + def test(): - vec10 = Vectors("data/chene_sessile.vec") + vec10 = Vectors(get_shared_data("chene_sessile.vec")) Plot(vec10) # plot of the pointwise averages Plot(Regression(vec10, "MovingAverage", 1, 2, [1])) @@ -111,4 +114,4 @@ def test(): if __name__ == "__main__": - test1() + test()