<commit_before>package com.github.TKnudsen.timeseries.operations.preprocessing.multivariate.uncertainty.processing;

import java.util.SortedMap;

import com.github.TKnudsen.ComplexDataObject.data.complexDataObject.ComplexDataObject;
import com.github.TKnudsen.ComplexDataObject.data.interfaces.ISelfDescription;
import com.github.TKnudsen.ComplexDataObject.data.uncertainty.IUncertainty;
import com.github.TKnudsen.ComplexDataObject.model.processors.IProcessingUncertaintyMeasure;
import com.github.TKnudsen.timeseries.data.ITimeSeries;
import com.github.TKnudsen.timeseries.data.ITimeSeriesListener;
import com.github.TKnudsen.timeseries.data.IUncertaintyAtTimeStamp;
import com.github.TKnudsen.timeseries.data.TimeSeriesEvent;
import com.github.TKnudsen.timeseries.data.multivariate.TimeSeriesMultivariate;

/**
 * <p>
 * Title: TimeSeriesProcessingUncertaintyMeasure
 * </p>
 * 
 * <p>
 * Description: Basic class for calculations of value uncertainty information of
 * a (time series) processor.
 * </p>
 * 
 * <p>
 * Copyright: Copyright (c) 2017-2018
 * </p>
 * 
 * @author <NAME>
 * @version 1.05
 */
public abstract class TimeSeriesProcessingUncertaintyMeasure<ITimeSeriesMultivariate, U extends IUncertainty<?>>
		extends ComplexDataObject implements IUncertaintyAtTimeStamp<U>, ISelfDescription,
		IProcessingUncertaintyMeasure<ITimeSeriesMultivariate, U>, ITimeSeriesListener {

	// TODO decide whether the uncertainties should rather be handed to some
	// obeserver instantly. Goal: avoid state variables in the measures.
	protected SortedMap<Long, U> uncertaintiesOverTime;

	@Override
	public U getUncertainty(Long timeStamp) {
		if (uncertaintiesOverTime == null) {
			System.err.println(getName() + ": no uncertainty information calculated yet.");
			return null;
		}

		return uncertaintiesOverTime.get(timeStamp);
	}

	@Override
	public U getUncertainty(int index) {
		throw new IllegalArgumentException(getName()
				+ "index-based access to uncertainty information of time series is unsafe and thus deprecated.");
	}

	@Override
	public void valueDomainChanged(TimeSeriesEvent learningDataEvent) {
		ITimeSeries<?> oldTimeSeries = learningDataEvent.getOldTimeSeries();
		if (oldTimeSeries.getClass().isAssignableFrom(TimeSeriesMultivariate.class))
			calculateUncertainty((ITimeSeriesMultivariate) learningDataEvent.getOldTimeSeries(),
					(ITimeSeriesMultivariate) learningDataEvent.getTimeSeries());
	}

	@Override
	public void temporalDomainChanged(TimeSeriesEvent learningDataEvent) {
		ITimeSeries<?> oldTimeSeries = learningDataEvent.getOldTimeSeries();
		if (oldTimeSeries.getClass().isAssignableFrom(TimeSeriesMultivariate.class))
			calculateUncertainty((ITimeSeriesMultivariate) learningDataEvent.getOldTimeSeries(),
					(ITimeSeriesMultivariate) learningDataEvent.getTimeSeries());
	}

	public SortedMap<Long, U> getUncertaintiesOverTime() {
		return uncertaintiesOverTime;
	}

}<commit_msg>add uncertainties over time, necessary for loading value uncertainties from file system<commit_after>package com.github.TKnudsen.timeseries.operations.preprocessing.multivariate.uncertainty.processing;

import java.util.SortedMap;

import com.github.TKnudsen.ComplexDataObject.data.complexDataObject.ComplexDataObject;
import com.github.TKnudsen.ComplexDataObject.data.interfaces.ISelfDescription;
import com.github.TKnudsen.ComplexDataObject.data.uncertainty.IUncertainty;
import com.github.TKnudsen.ComplexDataObject.model.processors.IProcessingUncertaintyMeasure;
import com.github.TKnudsen.timeseries.data.ITimeSeries;
import com.github.TKnudsen.timeseries.data.ITimeSeriesListener;
import com.github.TKnudsen.timeseries.data.IUncertaintyAtTimeStamp;
import com.github.TKnudsen.timeseries.data.TimeSeriesEvent;
import com.github.TKnudsen.timeseries.data.multivariate.TimeSeriesMultivariate;

/**
 * <p>
 * Title: TimeSeriesProcessingUncertaintyMeasure
 * </p>
 * 
 * <p>
 * Description: Basic class for calculations of value uncertainty information of
 * a (time series) processor.
 * </p>
 * 
 * <p>
 * Copyright: Copyright (c) 2017-2018
 * </p>
 * 
 * @author <NAME>
 * @version 1.05
 */
public abstract class TimeSeriesProcessingUncertaintyMeasure<ITimeSeriesMultivariate, U extends IUncertainty<?>>
		extends ComplexDataObject implements IUncertaintyAtTimeStamp<U>, ISelfDescription,
		IProcessingUncertaintyMeasure<ITimeSeriesMultivariate, U>, ITimeSeriesListener {

	// TODO decide whether the uncertainties should rather be handed to some
	// obeserver instantly. Goal: avoid state variables in the measures.
	protected SortedMap<Long, U> uncertaintiesOverTime;

	@Override
	public U getUncertainty(Long timeStamp) {
		if (uncertaintiesOverTime == null) {
			System.err.println(getName() + ": no uncertainty information calculated yet.");
			return null;
		}

		return uncertaintiesOverTime.get(timeStamp);
	}

	@Override
	public U getUncertainty(int index) {
		throw new IllegalArgumentException(getName()
				+ "index-based access to uncertainty information of time series is unsafe and thus deprecated.");
	}

	@Override
	public void valueDomainChanged(TimeSeriesEvent learningDataEvent) {
		ITimeSeries<?> oldTimeSeries = learningDataEvent.getOldTimeSeries();
		if (oldTimeSeries.getClass().isAssignableFrom(TimeSeriesMultivariate.class))
			calculateUncertainty((ITimeSeriesMultivariate) learningDataEvent.getOldTimeSeries(),
					(ITimeSeriesMultivariate) learningDataEvent.getTimeSeries());
	}

	@Override
	public void temporalDomainChanged(TimeSeriesEvent learningDataEvent) {
		ITimeSeries<?> oldTimeSeries = learningDataEvent.getOldTimeSeries();
		if (oldTimeSeries.getClass().isAssignableFrom(TimeSeriesMultivariate.class))
			calculateUncertainty((ITimeSeriesMultivariate) learningDataEvent.getOldTimeSeries(),
					(ITimeSeriesMultivariate) learningDataEvent.getTimeSeries());
	}

	public SortedMap<Long, U> getUncertaintiesOverTime() {
		return uncertaintiesOverTime;
	}

	public void addUncertaintiesOverTime(SortedMap<Long, U> uncertainties) {
		this.uncertaintiesOverTime = uncertainties;
	}
}
{'fraction_non_alphanumeric': 0.09214226633581472, 'fraction_numerical': 0.003639371381306865, 'mean_word_length': 6.51055900621118, 'pattern_counts': {'":': 2, '<': 34, '<?xml version=': 0, '>': 34, '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': '6967543', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1733, 'n_words': 346}