def posterior_samples(
    read_variable, metafile=False, default_analysis=None,
    print_parameters=True, samples_variable="posterior_samples", text=(
        "The posterior samples can be extracted through the `samples_dict` "
        "property. These posterior samples are stored in a custom "
        "table structure"
    )
):
    """Return a string showing how to extract the posterior samples from a
    result file

    Parameters
    ----------
    read_variable: str
        name of the read object
    metafile: Bool, optional
        if True, the result file is a pesummary meta file
    default_analysis: str, optional
        default analysis to use when `metafile=True`
    print_parameters: Bool, optional
        if True, print the parameters stored in the table
    samples_variable: str, optional
        name of the SamplesDict class
    text: str, optional
        Markdown text explaining how to extract posterior samples from the file
    """
    string = "samples_dict = {}.samples_dict\n".format(read_variable)
    if metafile:
        if default_analysis is None:
            raise ValueError("Please provide a default analysis")
        string += "{} = samples_dict['{}']\n".format(
            samples_variable, default_analysis
        )
    if print_parameters:
        string += "parameters = list({}.keys())\n".format(samples_variable)
        string += "print(parameters)"
    if text is not None:
        return [text, string]
    return [string]