コード例 #1
0
        public static void DoHistogramTest([NotNull] ITestOutputHelper output, [NotNull] IHistogramBuilder builder,
                                           [NotNull] double[] values, [NotNull] bool[] states)
        {
            var actualHistogram = builder.Build(new Statistics(values));

            Check(output, states, actualHistogram);
        }
コード例 #2
0
        /// <summary>
        /// Ignore column when building results
        /// </summary>
        /// <param name="builder">Current histogram builder</param>
        /// <param name="columnName">Column name to ignore</param>
        /// <returns>Current Histogram instance</returns>
        public static TBuilder Ignore <TData, TBuilder>(this IHistogramBuilder <TData, TBuilder> builder, string columnName)
            where TBuilder : IHistogramBuilder <TData, TBuilder>
        {
            builder.ColumnIgnoreNames.Add(columnName);

            return((TBuilder)builder);
        }
コード例 #3
0
        public static void DoHistogramTest([NotNull] ITestOutputHelper output, [NotNull] IHistogramBuilder builder,
                                           [NotNull] double[] values, double binSize, [NotNull] double[][] bins)
        {
            var actualHistogram = builder.BuildWithFixedBinSize(values, binSize);

            Check(output, bins, actualHistogram);
        }
コード例 #4
0
        /// <summary>
        /// Rename result columns to desired names
        /// </summary>
        /// <param name="builder">Current histogram builder</param>
        /// <param name="sourceColumnName">source column name</param>
        /// <param name="alias">Name to replace it with</param>
        /// <returns>Current Histogram instance</returns>
        public static TBuilder Alias <TData, TBuilder>(this IHistogramBuilder <TData, TBuilder> builder, string sourceColumnName, string alias)
            where TBuilder : IHistogramBuilder <TData, TBuilder>
        {
            builder.ColumnAliases.Add(sourceColumnName, alias);

            return((TBuilder)builder);
        }
コード例 #5
0
        /// <summary>
        /// Register dimension (aka X value)
        /// Each registered dimension will become part of composite key for aggregation.
        /// Think of each dimension as part of GROUP BY key.
        /// </summary>
        /// <param name="builder">Current histogram builder</param>
        /// <param name="dimension">dimension object</param>
        /// <returns>Current Histogram instance</returns>
        public static TBuilder Add <TData, TBuilder>(this IHistogramBuilder <TData, TBuilder> builder, IDimension <TData> dimension)
            where TBuilder : IHistogramBuilder <TData, TBuilder>
        {
            builder.Dimensions.Add(dimension);

            return((TBuilder)builder);
        }
コード例 #6
0
        public HistogramCreaterWindowViewModel(IHistogramBuilder histogramBuilder)
        {
            Data             = new ObservableCollection <SelectableObject <IVoxelDataStructure> >();
            ROIs             = new ObservableCollection <RegionOfInterest>();
            HistogramBuilder = histogramBuilder;

            SelectedData = new List <IVoxelDataStructure>();

            foreach (var item in Workspace.Workspace.Current.Doses.GetList())
            {
                AddData(item.Grid);
            }
            foreach (var item in Workspace.Workspace.Current.Images.GetList())
            {
                AddData(item.Grid);
            }
            foreach (var structureSet in Workspace.Workspace.Current.StructureSets.GetList())
            {
                foreach (var roi in structureSet.ROIs)
                {
                    ROIs.Add(roi);
                }
            }

            SelectedROI = ROIs.FirstOrDefault();

            MessengerInstance.Register <RTObjectAddedMessage <EgsDoseObject> >(this, x => AddData(x.Value.Grid));
            MessengerInstance.Register <RTObjectAddedMessage <DicomDoseObject> >(this, x => AddData(x.Value.Grid));
            MessengerInstance.Register <RTObjectAddedMessage <DicomImageObject> >(this, x => AddData(x.Value.Grid));
            MessengerInstance.Register <RTObjectAddedMessage <StructureSet> >(this, x => { foreach (var roi in x.Value.ROIs)
                                                                                           {
                                                                                               ROIs.Add(roi);
                                                                                           }
                                                                                           SelectedROI = x.Value.ROIs.FirstOrDefault(); });
        }
コード例 #7
0
        /// <summary>
        /// Register metric (aka Y value)
        /// Rows grouped by provided dimensions will be aggregated with registered metrics.
        /// </summary>
        /// <param name="builder">Current histogram builder</param>
        /// <param name="metric">metric object</param>
        /// <param name="postProcess">allows postprocessing of results/order for this metric before outputting it to the main results table.</param>
        /// <returns>Current Histogram instance</returns>
        public static TBuilder Add <TData, TBuilder>(this IHistogramBuilder <TData, TBuilder> builder, IMetric <TData> metric, PostProcessDelegate postProcess = null)
            where TBuilder : IHistogramBuilder <TData, TBuilder>
        {
            if (postProcess != null)
            {
                builder.MetricsPostProcess.Add(builder.Metrics.Count, postProcess);
            }

            builder.Metrics.Add(metric);

            return((TBuilder)builder);
        }
コード例 #8
0
        /// <summary>
        /// Generates <paramref name="count"/> count buckets, the first having the upper-incluse bound of start, others having an upper-inclusive bound that is the multiple of the previous bucket's upper-incluseive bound by <paramref name="factor"/>.
        /// An extra bucket is implicitly generated for values over the specified buckets (<see href="https://prometheus.io/docs/instrumenting/writing_clientlibs/#histogram"/>).
        ///
        /// The generated buckets are registered to <paramref name="builder"/>.
        /// </summary>
        /// <param name="builder">The builder to assign the buckets to.</param>
        /// <param name="start">Inclusive upper bound of lowest bucket. Must be positive, non-zero, finite number.</param>
        /// <param name="factor">The factor for scaling upper-inclusive bounds of subsequent buckets. Must be finite, greater than 1.</param>
        /// <param name="count">Number of intervals create buckets for. At least 1</param>
        /// <returns>the builder supplied in <paramref name="builder"/></returns>
        public static IHistogramBuilder ExponentialBuckets(this IHistogramBuilder builder, double start, double factor, int count)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var generator = new ExponentialBucketGenerator();

            var buckets = generator.ExponentialBuckets(start, factor, count);

            builder.Buckets(buckets);

            return(builder);
        }
コード例 #9
0
        /// <summary>
        /// Generates <paramref name="count"/> count buckets of equal <paramref name="width"/>, with the first having a lower bound of <see cref="double.NegativeInfinity"/> and upper-incluse bound of <paramref name="min"/>.
        /// An extra bucket is implicitly generated for values over the specified buckets (<see href="https://prometheus.io/docs/instrumenting/writing_clientlibs/#histogram"/>).
        ///
        /// The generated buckets are registered to <paramref name="builder"/>.
        /// </summary>
        /// <param name="builder">The builder to assign the buckets to</param>
        /// <param name="min">Inclusive upper bound of lowest bucket</param>
        /// <param name="width">The width of a bucket.</param>
        /// <param name="count">Number of intervals create buckets for. At least 1</param>
        /// <returns>the builder supplied in <paramref name="builder"/></returns>
        public static IHistogramBuilder LinearBuckets(this IHistogramBuilder builder, double min, double width, int count)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var generator = new LinearBucketGenerator();

            var buckets = generator.LinearBuckets(min, width, count);

            builder.Buckets(buckets);

            return(builder);
        }
コード例 #10
0
        /// <summary>
        /// Generates a continous series of buckets with the specified upper-inclusive bounds, with the first having a lower bound of <see cref="double.NegativeInfinity"/> and upper-incluse bound of the first item of <paramref name="bounds"/>.
        /// An extra bucket is implicitly generated for values over the specified buckets (<see href="https://prometheus.io/docs/instrumenting/writing_clientlibs/#histogram"/>).
        /// </summary>
        /// <param name="builder">The builder to assign the buckets to</param>
        /// <param name="bounds">The upper inclusive bounds of the buckets. Must be a non-empty, increasing series.</param>
        /// <returns>the builder supplied in <paramref name="builder"/></returns>
        public static IHistogramBuilder Buckets(this IHistogramBuilder builder, params double[] bounds)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var generator = new BucketGenerator();

            var buckets = generator.Buckets(bounds);

            builder.Buckets(buckets);

            return(builder);
        }
コード例 #11
0
        /// <summary>
        /// Copies histogram setup from source to target, overwriting all preexisting configuration in target
        /// </summary>
        public static void CopySettings <TData, THistogram>(this IHistogramBuilder <TData, THistogram> source, IHistogramBuilder <TData, THistogram> target)
        {
            target.Dimensions.Clear();
            target.Dimensions.AddRange(source.Dimensions);

            target.Metrics.Clear();
            target.Metrics.AddRange(source.Metrics);

            target.ColumnAliases.Clear();
            foreach (KeyValuePair <string, string> item in source.ColumnAliases)
            {
                target.ColumnAliases.Add(item.Key, item.Value);
            }

            target.ColumnIgnoreNames.Clear();
            target.ColumnIgnoreNames.AddRange(source.ColumnIgnoreNames);
        }
コード例 #12
0
        public void Buckets_for_IHistogramBuilder_null_builder_throws()
        {
            IHistogramBuilder builder = null;

            Assert.Throws <ArgumentNullException>("builder", () => builder.LinearBuckets(12, 34, 1));
        }
コード例 #13
0
        public void ExponentialBuckets_for_IHistogramBuilder_null_builder_throws()
        {
            IHistogramBuilder builder = null;

            Assert.Throws <ArgumentNullException>("builder", () => builder.ExponentialBuckets(1, 10, 3));
        }