<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using Reactive.Bindings;

namespace EpidemicSimulator
{
    public class MainViewModel
    {
        const int PopulationBarWidth = 800;

        public AppModel AppModel { get; } = new AppModel();

        public ReadOnlyReactiveProperty<byte[]> PopulationImage { get; }
        public ReadOnlyReactiveProperty<PopulationSummary> PopulationSummary { get; }
        public ReadOnlyReactiveProperty<PopulationLayout> PopulationLayout { get; }

        public MainViewModel()
        {
            PopulationImage = AppModel.InfectionSnapshot.Select(DataModelHelper.GetBitmapBinary).ToReadOnlyReactiveProperty();
            PopulationSummary = AppModel.InfectionSnapshot.Select(DataModelHelper.ToSummary).ToReadOnlyReactiveProperty();
            PopulationLayout = PopulationSummary.Select(ToLayout).ToReadOnlyReactiveProperty();
        }

        static PopulationLayout ToLayout(PopulationSummary s)
        {
            var width_s = (int)Math.Round(PopulationBarWidth * ((double)s.Susceptible / s.Total), MidpointRounding.AwayFromZero);
            var width_i = (int)Math.Round(PopulationBarWidth * ((double)s.Infectious / s.Total), MidpointRounding.AwayFromZero);

            return new PopulationLayout
            {
                SusceptibleWidth = width_s,
                InfectiousWidth = width_i,
                RecoveredWidth = PopulationBarWidth - width_s - width_i,
            };
        }
    }

    public struct PopulationLayout
    {
        public int SusceptibleWidth { get; set; }
        public int InfectiousWidth { get; set; }
        public int RecoveredWidth { get; set; }
    }
}<commit_msg>Improve code<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using Reactive.Bindings;

namespace EpidemicSimulator
{
    public class MainViewModel
    {
        const int PopulationBarWidth = 800;

        public AppModel AppModel { get; } = new AppModel();

        public ReadOnlyReactiveProperty<byte[]> PopulationImage { get; }
        public ReadOnlyReactiveProperty<PopulationSummary> PopulationSummary { get; }
        public ReadOnlyReactiveProperty<PopulationLayout> PopulationLayout { get; }

        public MainViewModel()
        {
            PopulationImage = AppModel.InfectionSnapshot.Select(DataModelHelper.GetBitmapBinary).ToReadOnlyReactiveProperty();
            PopulationSummary = AppModel.InfectionSnapshot.Select(DataModelHelper.ToSummary).ToReadOnlyReactiveProperty();
            PopulationLayout = PopulationSummary.Select(ToLayout).ToReadOnlyReactiveProperty();
        }

        static PopulationLayout ToLayout(PopulationSummary s)
        {
            var width_i = (int)Math.Round(PopulationBarWidth * ((double)s.Infectious / s.Total), MidpointRounding.AwayFromZero);
            var width_r = (int)Math.Round(PopulationBarWidth * ((double)s.Recovered / s.Total), MidpointRounding.AwayFromZero);

            return new PopulationLayout
            {
                SusceptibleWidth = PopulationBarWidth - width_i - width_r,
                InfectiousWidth = width_i,
                RecoveredWidth = width_r,
            };
        }
    }

    public struct PopulationLayout
    {
        public int SusceptibleWidth { get; set; }
        public int InfectiousWidth { get; set; }
        public int RecoveredWidth { get; set; }
    }
}
{'fraction_non_alphanumeric': 0.08066839527513685, 'fraction_numerical': 0.001728608470181504, 'mean_word_length': 2.883668903803132, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7584440', 'n_tokens_mistral': 947, 'n_tokens_neox': 877, 'n_words': 181}