<commit_before>#include "image/stride.h"

namespace MR
{
  namespace Image
  {

    namespace Stride
    {

      using namespace App;

      const OptionGroup StrideOption = OptionGroup ("Stride options")
      + Option ("stride",
                "specify the strides of the output data in memory, as a comma-separated list. "
                "The actual strides produced will depend on whether the output image "
                "format can support it.")
      + Argument ("spec").type_sequence_int();






      List& sanitise (List& strides, const List& ref)
      {
        // remove duplicates
        for (size_t i = 0; i < strides.size()-1; ++i) {
          if (!strides[i]) continue;
          for (size_t j = i+1; j < strides.size(); ++j) {
            if (!strides[j]) continue;
            if (abs (strides[i]) == abs (strides[j])) 
              strides[j] = 0;
          }
        }

        ssize_t max = 0;
        for (size_t i = 0; i < strides.size(); ++i)
          if (ref[i] && abs (strides[i]) > max)
            max = abs (strides[i]);

        assert (max > 0);

        for (size_t i = 0; i < strides.size(); ++i) {
          if (!ref[i]) {
            ++max;
            strides[i] = strides[i]<0 ? -max : max;
          }
        }
        symbolise (strides);
        return strides;
      }



    }
  }
}

<commit_msg>Image::Stride::sanitise() fix<commit_after>#include "image/stride.h"

namespace MR
{
  namespace Image
  {

    namespace Stride
    {

      using namespace App;

      const OptionGroup StrideOption = OptionGroup ("Stride options")
      + Option ("stride",
                "specify the strides of the output data in memory, as a comma-separated list. "
                "The actual strides produced will depend on whether the output image "
                "format can support it.")
      + Argument ("spec").type_sequence_int();






      List& sanitise (List& strides, const List& ref)
      {
        // remove duplicates
        for (size_t i = 0; i < strides.size()-1; ++i) {
          if (!strides[i]) continue;
          for (size_t j = i+1; j < strides.size(); ++j) {
            if (!strides[j]) continue;
            if (Math::abs (strides[i]) == Math::abs (strides[j]))
              strides[j] = 0;
          }
        }

        ssize_t max = 0;
        for (size_t i = 0; i < strides.size(); ++i)
          if (Math::abs (strides[i]) > max)
            max = Math::abs (strides[i]);

        assert (max > 0);

        for (size_t i = 0; i < strides.size(); ++i) {
          if (!strides[i])
            strides[i] = (Math::abs (ref[i]) + max) * (ref[i] < 0 ? -1 : 1);
        }
        symbolise (strides);
        return strides;
      }



    }
  }
}


{'fraction_non_alphanumeric': 0.13991920675725303, 'fraction_numerical': 0.007344840249724568, 'mean_word_length': 1.6784660766961652, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, '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': '7109018', 'n_tokens_mistral': 912, 'n_tokens_neox': 832, 'n_words': 251}