Repository: rhayes777/PyAutoFit (python)

Issue:
Wrong Samples type loaded via database
**Directory**

In the following script, we perform a fit using a nested sampler, but at the end of the script when we load the samples via the directory interface, we find the samples type is `SamplesPDF`:

https://github.com/Jammy2211/autofit_workspace_test/blob/main/bug/samples_directory_bug.py

The samples type should be `SamplesNest` -- but loading the wrong samples type certain methods are incorrect.

The reason for this is this function:

```
    @property
    def samples(self) -> SamplesPDF:
        """
        The samples of the search, parsed from a CSV containing individual samples
        and a JSON containing metadata.
        """
        if not self._samples:
            try:
                info_json = JSONOutput(
                    "info", self.files_path / "samples_info.json"
                ).dict

                with open(self.files_path / "samples.csv") as f:
                    sample_list = samples_from_iterator(csv.reader(f))

                self._samples = SamplesPDF.from_list_info_and_model(
                    sample_list=sample_list,
                    samples_info=info_json,
                    model=self.model,
                )
            except FileNotFoundError:
                raise AttributeError("No samples found")
        return self._samples
```

Therefore, we should update this function to return a samples type that corresponds to the correct type.

the samples above are loaded from `samples.csv`, which does not know the type of the search used to fit it and therefore cannot determine whether to load a `SamplesNest`, `SamplesMCMC` or something else.

I think there are two options for how we address this:

- Add the samples type to the `samples_info.json` file, which is loaded in the function above.
- Have the function above use the search (via `search.json`) to load the search and based on its instance choose the samples type.

**Database**

The following test script shows the same behaviour occurs when we load samples via a scraped .sqlite database:

https://github.com/Jammy2211/autofit_workspace_test/blob/main/bug/samples_scrape_bug.py

I don't think this occurs due to the same part of code shown above, but is instead a different module in the `database` package. Anyway, can you make it so we achieve the same behaviour of loading `SamplesNest` correctly.

Pull request description:
feature/sample type
Resolves #968


Patch:
diff --git a/autofit/aggregator/search_output.py b/autofit/aggregator/search_output.py
index 31424fb9b..df2f0c706 100644
--- a/autofit/aggregator/search_output.py
+++ b/autofit/aggregator/search_output.py
@@ -9,6 +9,8 @@ from typing import Generator, Tuple, Optional, List, cast
 import dill
 
 from autoconf import cached_property
+from autoconf.class_path import get_class
+from autofit.non_linear.samples import Samples
 
 from autofit.non_linear.samples.pdf import SamplesPDF
 from autofit.aggregator.file_output import (
@@ -246,7 +248,9 @@ class SearchOutput(AbstractSearchOutput):
                 with open(self.files_path / "samples.csv") as f:
                     sample_list = samples_from_iterator(csv.reader(f))
 
-                self._samples = SamplesPDF.from_list_info_and_model(
+                cls = cast(Samples, get_class(info_json["type"]))
+
+                self._samples = cls.from_list_info_and_model(
                     sample_list=sample_list,
                     samples_info=info_json,
                     model=self.model,
diff --git a/autofit/config/output.yaml b/autofit/config/output.yaml
index a9182824f..94ca0f7ae 100644
--- a/autofit/config/output.yaml
+++ b/autofit/config/output.yaml
@@ -21,23 +21,6 @@ default: true # If true then files which are not explicitly listed here are outp
 
 samples: true
 
-# The `samples.csv` file contains every accepted sampled value of every free parameter with its log likelihood and
-# weight. For certain searches, the majority of samples have a very low weight, which has no numerical impact on the
-# results of the model-fit. However, these samples are still output to the `samples.csv` file, taking up hard-disk space
-# and slowing down analysis of the samples (e.g. via the database).
-
-# The `samples_weight_threshold` below specifies the threshold value of the weight such that samples with a weight
-# below this value are not output to the `samples.csv` file. This can be used to reduce the size of the `samples.csv`
-# file and speed up analysis of the samples.
-
-# Note that for many searches (e.g. MCMC) all samples have equal weight, and thus this threshold has no impact and
-# there is no simple way to save hard-disk space. However, for nested sampling, the majority of samples have a very
-# low weight and this threshold can be used to save hard-disk space.
-
-# Set value to empty (e.g. delete 1.0e-10 below) to disable this feature.
-
-samples_weight_threshold: 1.0e-10
-
 ### Search Internal ###
 
 # The search internal folder which contains a saved state of the non-linear search, as a .pickle or .dill file.
diff --git a/autofit/database/model/__init__.py b/autofit/database/model/__init__.py
index 85adea703..65ffd1822 100644
--- a/autofit/database/model/__init__.py
+++ b/autofit/database/model/__init__.py
@@ -4,3 +4,4 @@ from .model import *
 from .prior import *
 from .array import *
 from .compound import *
+from .common import *
diff --git a/autofit/database/model/common.py b/autofit/database/model/common.py
new file mode 100644
index 000000000..75b71b741
--- /dev/null
+++ b/autofit/database/model/common.py
@@ -0,0 +1,36 @@
+from typing import Union
+
+from ..sqlalchemy_ import sa
+
+from autofit.mapper.prior import abstract
+from autofit.mapper.prior_model import prior_model
+from autofit.mapper.prior_model import collection
+
+from .model import Object
+
+
+class Dict(Object):
+    """
+    Represents a Python dictionary in the database
+    """
+
+    __tablename__ = "dict"
+
+    id = sa.Column(
+        sa.Integer,
+        sa.ForeignKey("object.id"),
+        primary_key=True,
+        index=True,
+    )
+
+    __mapper_args__ = {"polymorphic_identity": "dict"}
+
+    def __call__(self):
+        return {child.name: child() for child in self.children}
+
+    @classmethod
+    def _from_object(cls, source: dict):
+        instance = cls()
+        instance._add_children(source.items())
+        instance.cls = dict
+        return instance
diff --git a/autofit/database/model/model.py b/autofit/database/model/model.py
index 79e40ebca..edfce1f52 100644
--- a/autofit/database/model/model.py
+++ b/autofit/database/model/model.py
@@ -118,7 +118,11 @@ class Object(Base):
             from .instance import Collection
 
             instance = Collection._from_object(source)
-        elif isinstance(source, (Collection, dict)):
+        elif isinstance(source, dict):
+            from .common import Dict
+
+            instance = Dict._from_object(source)
+        elif isinstance(source, Collection):
             from .prior import Collection
 
             instance = Collection._from_object(source)
diff --git a/autofit/non_linear/paths/directory.py b/autofit/non_linear/paths/directory.py
index 8c929c8fd..375129a14 100644
--- a/autofit/non_linear/paths/directory.py
+++ b/autofit/non_linear/paths/directory.py
@@ -243,7 +243,7 @@ class DirectoryPaths(AbstractPaths):
             if isinstance(samples, SamplesPDF):
                 try:
                     samples.save_covariance_matrix(self._covariance_file)
-                except ValueError as e:
+                except (ValueError, ZeroDivisionError) as e:
                     logger.warning(
                         f"Could not save covariance matrix because of the following error:\n{e}"
                     )
diff --git a/autofit/non_linear/samples/efficient.py b/autofit/non_linear/samples/efficient.py
index e38eb8a8d..effedef30 100644
--- a/autofit/non_linear/samples/efficient.py
+++ b/autofit/non_linear/samples/efficient.py
@@ -1,7 +1,10 @@
-from typing import List
+from typing import List, cast, Type
 
 import numpy as np
+
+from autoconf.class_path import get_class
 from .sample import Sample
+from .samples import Samples
 from .pdf import SamplesPDF
 
 
@@ -20,7 +23,10 @@ class EfficientSamples:
         self.samples_info = samples.samples_info
 
         sample_list = samples.sample_list
-        self._keys = list(sample_list[0].kwargs.keys())
+        try:
+            self._keys = list(sample_list[0].kwargs.keys())
+        except IndexError:
+            self._keys = []
         self._values = np.asarray(
             [[sample.kwargs[key] for key in self._keys] for sample in sample_list]
         )
@@ -31,11 +37,12 @@ class EfficientSamples:
         self._weights = np.asarray([sample.weight for sample in sample_list])
 
     @property
-    def samples(self) -> SamplesPDF:
+    def samples(self) -> Samples:
         """
         Convert the efficient samples back to a SamplesPDF instance.
         """
-        return SamplesPDF(
+        cls = cast(Type[Samples], get_class(self.samples_info["type"]))
+        return cls(
             model=self.model,
             samples_info=self.samples_info,
             sample_list=self.sample_list,
diff --git a/autofit/non_linear/samples/nest.py b/autofit/non_linear/samples/nest.py
index b0cdebc14..ea2c72aae 100644
--- a/autofit/non_linear/samples/nest.py
+++ b/autofit/non_linear/samples/nest.py
@@ -89,7 +89,7 @@ class SamplesNest(SamplesPDF):
         """
         The total number of accepted samples performed by the nested sampler.
         """
-        return self.samples_info["total_accepted_samples"]
+        return len(self.log_likelihood_list)
 
     @property
     def acceptance_ratio(self) -> float:
diff --git a/autofit/non_linear/samples/samples.py b/autofit/non_linear/samples/samples.py
index 8d692af50..b286c7e46 100644
--- a/autofit/non_linear/samples/samples.py
+++ b/autofit/non_linear/samples/samples.py
@@ -7,6 +7,7 @@ from typing import Dict, List, Optional, Tuple, Union
 
 import numpy as np
 
+from autoconf.class_path import get_class_path
 from autofit import exc
 from autofit.mapper.model import ModelInstance
 from autofit.mapper.prior_model.abstract import AbstractPriorModel
@@ -48,7 +49,10 @@ class Samples(SamplesInterface, ABC):
         super().__init__(model=model)
 
         self.sample_list = sample_list
-        self.samples_info = samples_info
+        self.samples_info = {
+            **(samples_info or {}),
+            "type": get_class_path(self.__class__),
+        }
 
     def __str__(self):
         return f"{self.__class__.__name__}({len(self.sample_list)})"
@@ -382,37 +386,6 @@ class Samples(SamplesInterface, ABC):
         """
         return self.parameter_lists[sample_index]
 
-    def samples_above_weight_threshold_from(self, weight_threshold: float) -> "Samples":
-        """
-        Returns a new `Samples` object containing only the samples with a weight above the input threshold.
-
-        This function can be used after a non-linear search is complete, to reduce the samples to only the high weight
-        values. The benefit of this is that the corresponding `samples.csv` file will be reduced in hard-disk size.
-
-        For large libraries of results can significantly reduce the overall hard-disk space used and speed up the
-        time taken to load the samples from a .csv file and perform analysis on them.
-
-        For a sufficiently low threshold, this has a neglible impact on the numerical accuracy of the results, and
-        even higher values can be used for aggresive use cases where hard-disk space is at a premium.
-
-        Parameters
-        ----------
-        weight_threshold
-            The threshold of weight at which a sample is included in the new `Samples` object.
-        """
-        sample_list = []
-
-        for sample in self.sample_list:
-            if sample.weight > weight_threshold:
-                sample_list.append(sample)
-
-        return self.__class__(
-            model=self.model,
-            sample_list=sample_list,
-            samples_info=self.samples_info,
-        )
-
-
     def minimise(self) -> "Samples":
         """
         A copy of this object with only important samples retained
@@ -488,4 +461,4 @@ class Samples(SamplesInterface, ABC):
         copied.model = model
 
         copied.sample_list = [sample.subsample(path_map) for sample in self.sample_list]
-        return copied
\ No newline at end of file
+        return copied
diff --git a/autofit/non_linear/search/abstract_search.py b/autofit/non_linear/search/abstract_search.py
index a5e841a32..ff0931559 100644
--- a/autofit/non_linear/search/abstract_search.py
+++ b/autofit/non_linear/search/abstract_search.py
@@ -560,7 +560,6 @@ class NonLinearSearch(AbstractFactorOptimiser, ABC):
 
             self.post_fit_output(
                 bypass_nuclear_if_on=bypass_nuclear_if_on,
-                search_internal=result.search_internal
             )
 
         return result
@@ -762,7 +761,7 @@ class NonLinearSearch(AbstractFactorOptimiser, ABC):
 
         return result
 
-    def post_fit_output(self, search_internal, bypass_nuclear_if_on: bool):
+    def post_fit_output(self, bypass_nuclear_if_on: bool):
         """
         Cleans up the output folderds after a completed non-linear search.
 
@@ -781,8 +780,6 @@ class NonLinearSearch(AbstractFactorOptimiser, ABC):
         if not conf.instance["output"]["search_internal"]:
             self.logger.info("Removing search internal folder.")
             self.paths.remove_search_internal()
-        else:
-            self.output_search_internal(search_internal=search_internal)
 
         self.logger.info("Removing all files except for .zip file")
         self.paths.zip_remove()
@@ -858,11 +855,6 @@ class NonLinearSearch(AbstractFactorOptimiser, ABC):
         """
         return self._class_config[section][attribute_name]
 
-    def output_search_internal(self, search_internal):
-        self.paths.save_search_internal(
-            obj=search_internal,
-        )
-
     def perform_update(
         self,
         model: AbstractPriorModel,
@@ -899,13 +891,13 @@ class NonLinearSearch(AbstractFactorOptimiser, ABC):
         self.iterations += self.iterations_per_update
         if during_analysis:
             self.logger.info(
-                f"""Fit Still Running: Updating results after {self.iterations} iterations (see
-                output folder for latest visualization, samples, etc.)"""
+                f"Fit Still Running: Updating results after {self.iterations} iterations (see "
+                f"output folder for latest visualization, samples, etc.)"
             )
         else:
             self.logger.info(
-                "Fit Complete: Updating final results (see "
-                "output folder for final visualization, samples, etc.)"
+                f"Fit Complete: Updating final results (see "
+                f"output folder for final visualization, samples, etc.)"
             )
 
         if not isinstance(self.paths, DatabasePaths) and not isinstance(
@@ -921,22 +913,7 @@ class NonLinearSearch(AbstractFactorOptimiser, ABC):
             return samples
 
         if self.is_master:
-
-            samples_for_csv = samples
-
-            samples_weight_threshold = conf.instance["output"]["samples_weight_threshold"]
-
-            if samples_weight_threshold is not None:
-                samples_for_csv = samples_for_csv.samples_above_weight_threshold_from(
-                    weight_threshold=samples_weight_threshold
-                )
-
-                logger.info(
-                    f"Samples with weight less than {samples_weight_threshold} removed from samples.csv and not used to "
-                    f"compute parameter estimates errors, etc."
-                )
-
-            self.paths.save_samples(samples=samples_for_csv)
+            self.paths.save_samples(samples=samples)
 
             latent_variables = analysis.latent_variables
             if latent_variables:
diff --git a/autofit/non_linear/search/mcmc/emcee/search.py b/autofit/non_linear/search/mcmc/emcee/search.py
index 57830d33f..8fd0f7f62 100644
--- a/autofit/non_linear/search/mcmc/emcee/search.py
+++ b/autofit/non_linear/search/mcmc/emcee/search.py
@@ -198,20 +198,6 @@ class Emcee(AbstractMCMC):
 
         return search_internal
 
-    def output_search_internal(self, search_internal):
-        """
-        Output the sampler results to hard-disk in their internal format.
-
-        Emcee uses a backend to store and load results, therefore the outputting of the search internal to a
-        dill file is disabled.
-
-        Parameters
-        ----------
-        sampler
-            The nautilus sampler object containing the results of the model-fit.
-        """
-        pass
-
     def samples_info_from(self, search_internal=None):
 
         search_internal = search_internal or self.backend
diff --git a/autofit/non_linear/search/nest/dynesty/search/abstract.py b/autofit/non_linear/search/nest/dynesty/search/abstract.py
index afed6c3c6..d301a1da9 100644
--- a/autofit/non_linear/search/nest/dynesty/search/abstract.py
+++ b/autofit/non_linear/search/nest/dynesty/search/abstract.py
@@ -199,6 +199,10 @@ class AbstractDynesty(AbstractNest, ABC):
                     during_analysis=True,
                 )
 
+        self.paths.save_search_internal(
+            obj=search_internal,
+        )
+
         return search_internal
 
     def samples_info_from(self, search_internal=None):
@@ -207,7 +211,6 @@ class AbstractDynesty(AbstractNest, ABC):
         return {
             "log_evidence": np.max(search_internal.results.logz),
             "total_samples": int(np.sum(search_internal.results.ncall)),
-            "total_accepted_samples": len(search_internal.results.logl),
             "time": self.timer.time if self.timer else None,
             "number_live_points": self.number_live_points,
         }
diff --git a/autofit/non_linear/search/nest/nautilus/search.py b/autofit/non_linear/search/nest/nautilus/search.py
index 73cddeaa0..65e7d5fa1 100644
--- a/autofit/non_linear/search/nest/nautilus/search.py
+++ b/autofit/non_linear/search/nest/nautilus/search.py
@@ -159,9 +159,10 @@ class Nautilus(abstract_nest.AbstractNest):
                 )
 
         if self.checkpoint_file is not None:
-
             os.remove(self.checkpoint_file)
 
+
+
         return search_internal
 
     @property
@@ -322,6 +323,8 @@ class Nautilus(abstract_nest.AbstractNest):
                     search_internal=search_internal
                 )
 
+                self.output_search_internal(search_internal=search_internal)
+
         return search_internal
 
     def fit_mpi(self, fitness, model, analysis, checkpoint_exists: bool):
@@ -367,6 +370,7 @@ class Nautilus(abstract_nest.AbstractNest):
 
             if checkpoint_exists:
                 if self.is_master:
+                    self.output_search_internal(search_internal=search_internal)
 
                     self.perform_update(
                         model=model,
@@ -379,6 +383,8 @@ class Nautilus(abstract_nest.AbstractNest):
                 **self.config_dict_run,
             )
 
+            self.output_search_internal(search_internal=search_internal)
+
         return search_internal
 
     def iterations_from(
@@ -453,7 +459,6 @@ class Nautilus(abstract_nest.AbstractNest):
         return {
             "log_evidence": search_internal.evidence(),
             "total_samples": int(search_internal.n_like),
-            "total_accepted_samples": int(search_internal.n_like),
             "time": self.timer.time if self.timer else None,
             "number_live_points": int(search_internal.n_live),
         }
diff --git a/autofit/non_linear/search/nest/ultranest/search.py b/autofit/non_linear/search/nest/ultranest/search.py
index dd82f5d62..07f208fb0 100644
--- a/autofit/non_linear/search/nest/ultranest/search.py
+++ b/autofit/non_linear/search/nest/ultranest/search.py
@@ -207,22 +207,6 @@ class UltraNest(abstract_nest.AbstractNest):
 
         return search_internal
 
-    def output_search_internal(self, search_internal):
-        """
-        Output the sampler results to hard-disk in their internal format.
-
-        UltraNest uses a backend to store and load results, therefore the outputting of the search internal to a
-        dill file is disabled.
-
-        However, a dictionary of the search results is output to dill above.
-
-        Parameters
-        ----------
-        sampler
-            The nautilus sampler object containing the results of the model-fit.
-        """
-        pass
-
     def samples_info_from(self, search_internal=None):
 
         search_internal = search_internal or self.paths.load_search_internal()
@@ -230,7 +214,6 @@ class UltraNest(abstract_nest.AbstractNest):
         return {
             "log_evidence": search_internal["logz"],
             "total_samples": search_internal["ncall"],
-            "total_accepted_samples": len(search_internal["weighted_samples"]["logl"]),
             "time": self.timer.time if self.timer else None,
             "number_live_points": self.config_dict_run["min_num_live_points"]
         }
diff --git a/docs/cookbooks/search.rst b/docs/cookbooks/search.rst
index 88b9b1984..0a232eb4c 100644
--- a/docs/cookbooks/search.rst
+++ b/docs/cookbooks/search.rst
@@ -11,7 +11,6 @@ It first covers standard options available for all non-linear searches:
 
 - **Example Fit**: A simple example of a non-linear search to remind us how it works.
 - **Output To Hard-Disk**: Output results to hard-disk so they can be inspected and used to restart a crashed search.
-- **Output Customization**: Customize the output of a non-linear search to hard-disk.
 - **Unique Identifier**: Ensure results are output in unique folders, so tthey do not overwrite each other.
 - **Iterations Per Update**: Control how often non-linear searches output results to hard-disk.
 - **Parallelization**: Use parallel processing to speed up the sampling of parameter space.
@@ -79,32 +78,6 @@ These outputs are fully described in the scientific workflow example.
 
     search = af.Emcee(path_prefix=path.join("folder_0", "folder_1"), name="example_mcmc")
 
-Output Customization
---------------------
-
-For large model fitting problems outputs may use up a lot of hard-disk space, therefore full customization of the 
-outputs is supported. 
-
-This is controlled by the ``output.yaml`` config file found in the ``config`` folder of the workspace. This file contains
-a full description of all customization options.
-
-A few examples of the options available include:
-
-- Control over every file which is output to the ``files`` folder (e.g. ``model.json``, ``samples.csv``, etc.).
-
-- For the ``samples.csv`` file, all samples with a weight below a certain value can be automatically removed.
-
-- Customization of the ``samples_summary.json`` file, which summarizes the results of the model-fit  (e.g. the maximum 
-  log likelihood model, the median PDF model and 3 sigma error). These results are computed using the full set of
-  samples, ensuring samples removal via a weight cut does not impact the results.
-
-In many use cases, the ``samples.csv`` takes up the significant majority of the hard-disk space, which for large-scale
-model-fitting problems can exceed gigabytes and be prohibitive to the analysis. 
-
-Careful customization of the ``output.yaml`` file enables a workflow where the ``samples.csv`` file is never output, 
-but all important information is output in the ``samples_summary.json`` file using the full samples to compute all 
-results to high numerical accuracy.
-
 Unique Identifier
 -----------------
 


Test patch:
diff --git a/test_autofit/non_linear/samples/test_nest.py b/test_autofit/non_linear/samples/test_nest.py
index 58a0f2381..e691cfab1 100644
--- a/test_autofit/non_linear/samples/test_nest.py
+++ b/test_autofit/non_linear/samples/test_nest.py
@@ -72,7 +72,6 @@ def test__acceptance_ratio_is_correct():
             "total_samples" : 10,
             "log_evidence" : 0.0,
             "number_live_points" : 5,
-            "total_accepted_samples": 5
             }
     )
 
diff --git a/test_autofit/non_linear/samples/test_output_type.py b/test_autofit/non_linear/samples/test_output_type.py
new file mode 100644
index 000000000..58cb2823b
--- /dev/null
+++ b/test_autofit/non_linear/samples/test_output_type.py
@@ -0,0 +1,38 @@
+import pytest
+
+import autofit as af
+from autoconf.conf import with_config
+from autofit import SamplesNest, SearchOutput
+from autofit.non_linear.samples.efficient import EfficientSamples
+
+
+@pytest.fixture(name="samples")
+def make_samples():
+    return SamplesNest(
+        model=af.Model(af.Gaussian),
+        sample_list=[],
+        samples_info=None,
+    )
+
+
+@with_config(
+    "general",
+    "output",
+    "samples_to_csv",
+    value=True,
+)
+def test_search_output(output_directory, samples):
+    paths = af.DirectoryPaths(
+        "name",
+        path_prefix=output_directory,
+    )
+    paths.save_samples(samples=samples)
+
+    search_output = SearchOutput(paths.output_path)
+
+    assert isinstance(search_output.samples, SamplesNest)
+
+
+def test_efficient_samples_type(samples):
+    efficient = EfficientSamples(samples=samples)
+    assert isinstance(efficient.samples, SamplesNest)
diff --git a/test_autofit/non_linear/samples/test_samples.py b/test_autofit/non_linear/samples/test_samples.py
index 40c5f45a5..35436b6f4 100644
--- a/test_autofit/non_linear/samples/test_samples.py
+++ b/test_autofit/non_linear/samples/test_samples.py
@@ -134,36 +134,6 @@ def test__instance_from_sample_index():
     assert instance.mock_class.four == 4.0
 
 
-def test__samples_above_weight_threshold_from():
-
-    model = af.Collection(mock_class=af.m.MockClassx4)
-
-    parameters = [
-        [1.0, 2.0, 3.0, 4.0],
-        [5.0, 6.0, 7.0, 8.0],
-        [1.0, 2.0, 3.0, 4.0],
-        [1.0, 2.0, 3.0, 4.0],
-        [1.1, 2.1, 3.1, 4.1],
-    ]
-
-    samples_x5 = af.m.MockSamples(
-        model=model,
-        sample_list=af.Sample.from_lists(
-            model=model,
-            parameter_lists=parameters,
-            log_likelihood_list=[0.0, 0.0, 0.0, 0.0, 0.0],
-            log_prior_list=[0.0, 0.0, 0.0, 0.0, 0.0],
-            weight_list=[0.2, 0.2, 1.0, 1.0, 1.0],
-        ),
-    )
-
-    samples_above_weight_threshold = samples_x5.samples_above_weight_threshold_from(
-        weight_threshold=0.5
-    )
-
-    assert len(samples_above_weight_threshold) == 3
-    assert samples_above_weight_threshold.sample_list[0].weight == 1.0
-
 def test__addition_of_samples(samples_x5):
     samples = samples_x5 + samples_x5
 
diff --git a/test_autofit/text/test_text_util.py b/test_autofit/text/test_text_util.py
index 532c5f51e..465b48796 100644
--- a/test_autofit/text/test_text_util.py
+++ b/test_autofit/text/test_text_util.py
@@ -57,7 +57,6 @@ def test__search_summary_to_file(model):
         ),
         samples_info={
             "time": "1",
-            "total_accepted_samples" : 2
         }
     )
 
@@ -83,7 +82,6 @@ def test__search_summary_to_file(model):
         ),
         samples_info={
             "total_samples": 10,
-            "total_accepted_samples": 2,
             "time": "1",
             "number_live_points": 1,
             "log_evidence": 1.0