<commit_before>#include "pixelmap.h"

using namespace pixelmap;

namespace pixelmap {

template <typename Type>
Type PushQueue(Type* array, int length, Type value) {
  Type rtrn = array[length - 1];
  for (int i = (length - 1); i > 0; i--) {
    array[i] = array[i - 1];
  }
  array[0] = value;
  return rtrn;
}

RippleVisualization::RippleVisualization(Input* input, int size)
  : Visualization(input, size)
  {
    for (int i = 0; i < smoothing_length_; i++) {
      smoothing_[i] = 0.0;
    }
  }

void RippleVisualization::update() {
  float value = input->getInput();


  float sum = 0.0;
  for (int i = 0; i < smoothing_length_; i++) {
    sum += smoothing_[i];
  }
  sum += value;
  value = sum / (float)(smoothing_length_ + 1);

  PushQueue(smoothing_, smoothing_length_, value);

  int hue = (int)(value * 255.0);
  CRGB color = CHSV(hue, 255, 255);
  PushQueue(viz, size_, color);
}

} // end namespace pixelmap<commit_msg>Ripples go purple -> red when input goes from 0 -> 1<commit_after>#include "pixelmap.h"

using namespace pixelmap;

namespace pixelmap {

template <typename Type>
Type PushQueue(Type* array, int length, Type value) {
  Type rtrn = array[length - 1];
  for (int i = (length - 1); i > 0; i--) {
    array[i] = array[i - 1];
  }
  array[0] = value;
  return rtrn;
}

RippleVisualization::RippleVisualization(Input* input, int size)
  : Visualization(input, size)
  {
    for (int i = 0; i < smoothing_length_; i++) {
      smoothing_[i] = 0.0;
    }
  }

void RippleVisualization::update() {
  float value = input->getInput();

  float sum = 0.0;
  for (int i = 0; i < smoothing_length_; i++) {
    sum += smoothing_[i];
  }
  sum += value;
  value = sum / (float)(smoothing_length_ + 1);

  PushQueue(smoothing_, smoothing_length_, value);

  int hue = 192 + (-value * 192);
  CRGB color = CHSV(hue, 255, 255);
  PushQueue(viz, size_, color);
}

} // end namespace pixelmap
{'fraction_non_alphanumeric': 0.15178571428571427, 'fraction_numerical': 0.025210084033613446, 'mean_word_length': 3.3592677345537756, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '7444436', 'n_tokens_mistral': 764, 'n_tokens_neox': 681, 'n_words': 193}