Skip to content

Commit

Permalink
Merge pull request #996 from rhayes777/feature/commented_tests
Browse files Browse the repository at this point in the history
feature/commented tests
  • Loading branch information
rhayes777 authored Apr 15, 2024
2 parents 624b278 + ed2a6e8 commit 14bdc44
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 36 deletions.
31 changes: 8 additions & 23 deletions autofit/non_linear/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


class Placeholder:

def __getattr__(self, item):
"""
Placeholders return None to represent the missing result's value
Expand Down Expand Up @@ -49,6 +48,9 @@ def summary(self):


class AbstractResult(ABC):
"""
@DynamicAttrs
"""

def __init__(self, samples_summary, paths):
"""
Expand All @@ -65,17 +67,6 @@ def __init__(self, samples_summary, paths):
self._samples_summary = samples_summary
self.paths = paths

def __getattr__(self, name):
"""
The Result object may be overwritten and extended by projects wrapping autofit.
lint errpors commonly occur because the Result object does not contain the attribute that is being accessed.
This method is used to disable these errors.
"""
warnings.warn('No member "%s" contained Result.' % name)
return super().__getattribute__(name)

@property
def samples_summary(self):
return self._samples_summary
Expand Down Expand Up @@ -122,7 +113,6 @@ def log_likelihood(self):

@property
def instance(self):

try:
return self.samples_summary.instance
except AttributeError as e:
Expand Down Expand Up @@ -204,11 +194,11 @@ def model_bounded(self, b: float) -> AbstractPriorModel:
class Result(AbstractResult):
def __init__(
self,
samples_summary : SamplesSummary,
paths : Optional[AbstractPaths] = None,
samples_summary: SamplesSummary,
paths: Optional[AbstractPaths] = None,
samples: Optional[Samples] = None,
search_internal : Optional[object] = None,
analysis : Optional[Analysis] = None
search_internal: Optional[object] = None,
analysis: Optional[Analysis] = None,
):
"""
The result of a non-linear search.
Expand Down Expand Up @@ -255,10 +245,7 @@ def __init__(
analysis
The `Analysis` object that was used to perform the model-fit from which this result is inferred.
"""
super().__init__(
samples_summary=samples_summary,
paths=paths
)
super().__init__(samples_summary=samples_summary, paths=paths)

self._samples = samples
self._search_internal = search_internal
Expand All @@ -269,8 +256,6 @@ def __init__(

self.child_results = None



def dict(self) -> dict:
"""
Human-readable dictionary representation of the results
Expand Down
27 changes: 14 additions & 13 deletions test_autofit/interpolator/test_covariance.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,26 @@ def test_covariance_matrix(interpolator):
# def test_interpolate(interpolator):
# assert isinstance(interpolator[interpolator.t == 0.5].gaussian.centre, float)


#
# def test_interpolate_other_field(interpolator):
# assert isinstance(
# interpolator[interpolator.gaussian.centre == 0.5].gaussian.centre,
# float,
# )
#
#
# def test_linear_analysis_for_value(interpolator):
# analysis = interpolator._analysis_for_value(interpolator.t == 0.5)
# assert (analysis.x == np.array([0, 1, 2])).all()
# assert (analysis.y == np.array([0, 0, 0, 1, 1, 1, 2, 2, 2])).all()
#
#
# def test_model(interpolator):
# model = interpolator.model()
# assert model.prior_count == 6
#
#


def test_linear_analysis_for_value(interpolator):
analysis = interpolator._analysis_for_value(interpolator.t == 0.5)
assert (analysis.x == np.array([0, 1, 2])).all()
assert (analysis.y == np.array([0, 0, 0, 1, 1, 1, 2, 2, 2])).all()


def test_model(interpolator):
model = interpolator.model()
assert model.prior_count == 6


# def test_single_variable():
# samples_list = [
# af.SamplesPDF(
Expand Down

0 comments on commit 14bdc44

Please sign in to comment.