Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/sub analysis aggregator #708

Merged
merged 14 commits into from
May 15, 2023
Merged

Conversation

rhayes777
Copy link
Owner

@rhayes777 rhayes777 commented May 10, 2023

Resolves #705.

Values from child analyses can be obtained using the child_values method

aggregator.child_values('data')

Fits which are not top-level are filtered out during aggregation. These fits can be included by setting a flag.

aggregator = af.Aggregator.from_database('filename', top_level_only=False)

@codecov
Copy link

codecov bot commented May 10, 2023

Codecov Report

Merging #708 (e1d0e18) into main (bf059ae) will increase coverage by 0.10%.
The diff coverage is n/a.

❗ Current head e1d0e18 differs from pull request most recent head 822fed5. Consider uploading reports for the commit 822fed5 to get more accurate results

@@            Coverage Diff             @@
##             main     #708      +/-   ##
==========================================
+ Coverage   81.78%   81.89%   +0.10%     
==========================================
  Files         180      180              
  Lines       13190    13219      +29     
==========================================
+ Hits        10788    10826      +38     
+ Misses       2402     2393       -9     

see 8 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Jammy2211
Copy link
Collaborator

This seems to work:

def _data_from(fit: af.Fit):

    data = fit.value(name="data")

    return data

data_gen = agg.child_values(name="data")

data = [data for data in data_gen]

Is there any way to do the child_values in the generator, so something like:

def _data_from(fit: af.Fit):

    data = fit.child_values(name="data")

    return data

data_gen = agg.values(name="data")

data = [data for data in data_gen]

I probably doesn't matter but would make it easier to maintain a consistent API in places.

@Jammy2211
Copy link
Collaborator

The reason is that generators may combine the two types of fits:

def _dataset_1d_from(fit: af.Fit, settings_dataset: Optional[SettingsDataset1D] = None):
    """
    Returns a `Dataset1D` object from an aggregator's `SearchOutput` class, which we call an 'agg_obj' to describe
    that it acts as the aggregator object for one result in the `Aggregator`. This uses the aggregator's generator
    outputs such that the function can use the `Aggregator`'s map function to create a `Dataset1D` generator.

     The `Dataset1D` is created following the same method as the PyAutoCTI `Search` classes, including using the
    `SettingsDataset1D` instance output by the Search to load inputs of the `Dataset1D`.

    Parameters
    ----------
    fit
        A PyAutoFit aggregator's SearchOutput object containing the generators of the results of model-fits.
    """

    dataset_list = fit.child_values(name="dataset")

    settings_dataset = settings_dataset or fit.value(name="settings_dataset")

    for dataset in dataset_list:

        dataset.apply_settings(settings=settings_dataset)

    return dataset

@rhayes777
Copy link
Owner Author

Done

@Jammy2211 Jammy2211 merged commit dd0a2ec into main May 15, 2023
@Jammy2211 Jammy2211 deleted the feature/sub_analysis_aggregator branch July 18, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Database support for CombinedAnalysis
2 participants