<commit_before>package dr.evomodel.continuous;

import dr.xml.*;
import dr.evolution.tree.BranchAttributeProvider;

/*
 * @author <NAME>
 */
public class BranchMagnitudeAttributeProvider extends BivariateTraitBranchAttributeProvider {

    public static final String MAGNITUDE_PROVIDER = "branchMagnitudes";
    public static final String SCALE = "scaleByLength";
    public static String DISTANCE_EXTENSION = ".distance";
    public static final String RATE_EXTENSION = ".rate";

    public BranchMagnitudeAttributeProvider(SampledMultivariateTraitLikelihood traitLikelihood, boolean scale) {
        super(traitLikelihood);
        this.scale = scale;
    }

    protected String extensionName() {
        if (scale)
            return RATE_EXTENSION;
        return DISTANCE_EXTENSION;
    }

    protected double convert(double latValue, double longValue, double timeValue) {
        double result = Math.sqrt(latValue*latValue + longValue*longValue);
        if (scale)
            result /= timeValue;
        return result;
    }<commit_msg>Add branch attribute providers that report direction of diffusion, distance and rate along each branch<commit_after>package dr.evomodel.continuous;

import dr.xml.*;
import dr.evolution.tree.BranchAttributeProvider;

/*
 * @author <NAME>
 */
public class BranchMagnitudeAttributeProvider extends BivariateTraitBranchAttributeProvider {

    public static final String MAGNITUDE_PROVIDER = "branchMagnitudes";
    public static final String SCALE = "scaleByLength";
    public static String DISTANCE_EXTENSION = ".distance";
    public static final String RATE_EXTENSION = ".rate";

    public BranchMagnitudeAttributeProvider(SampledMultivariateTraitLikelihood traitLikelihood, boolean scale) {
        super(traitLikelihood);
        this.scale = scale;
        label = traitName + extensionName(); 
    }

    protected String extensionName() {
        if (scale)
            return RATE_EXTENSION;
        return DISTANCE_EXTENSION;
    }

    protected double convert(double latValue, double longValue, double timeValue) {
        double result = Math.sqrt(latValue*latValue + longValue*longValue);
        if (scale)
            result /= timeValue;
        return result;
    }
{'fraction_non_alphanumeric': 0.07440609592111161, 'fraction_numerical': 0.0, 'mean_word_length': 3.5644171779141103, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '937248', 'n_tokens_mistral': 615, 'n_tokens_neox': 584, 'n_words': 159}