class_docstr: A class for building a MorphLut from a descriptive language
  
  The input patterns is a list of a strings sequences like these::
  
      4:(...
         .1.
         111)->1
  
  (whitespaces including linebreaks are ignored). The option 4
  describes a series of symmetry operations (in this case a
  4-rotation), the pattern is described by:
  
  - . or X - Ignore
  - 1 - Pixel is on
  - 0 - Pixel is off
  
  The result of the operation is described after "->" string.
  
  The default is to return the current pixel value, which is
  returned if no other match is found.
  
  Operations:
  
  - 4 - 4 way rotation
  - N - Negate
  - 1 - Dummy op for no other operation (an op must always be given)
  - M - Mirroring
  
  Example::
  
      lb = LutBuilder(patterns = ["4:(... .1. 111)->1"])
      lut = lb.build_lut()
class_docstr_tok: ["A","class","for","building","a","MorphLut","from","a","descriptive","language","The","input","patterns","is","a","list","of","a","strings","sequences","like","these",":",":","4",":","(","...",".1",".","111",")","-",">","1","(","whitespaces","including","linebreaks","are","ignored",")",".","The","option","4","describes","a","series","of","symmetry","operations","(","in","this","case","a","4-rotation",")",",","the","pattern","is","described","by",":","-",".","or","X","-","Ignore","-","1","-","Pixel","is","on","-","0","-","Pixel","is","off","The","result","of","the","operation","is","described","after","``","-",">","''","string",".","The","default","is","to","return","the","current","pixel","value",",","which","is","returned","if","no","other","match","is","found",".","Operations",":","-","4","-","4","way","rotation","-","N","-","Negate","-","1","-","Dummy","op","for","no","other","operation","(","an","op","must","always","be","given",")","-","M","-","Mirroring","Example",":",":","lb","=","LutBuilder","(","patterns","=","[","``","4",":","(","...",".1",".","111",")","-",">","1","''","]",")","lut","=","lb.build_lut","(",")"]
docstr: pattern_permute takes a basic pattern and its result and clones
  the pattern according to the modifications described in the $options
  parameter. It returns a list of all cloned patterns.
docstr_tok: ["pattern_permute","takes","a","basic","pattern","and","its","result","and","clones","the","pattern","according","to","the","modifications","described","in","the","$","options","parameter",".","It","returns","a","list","of","all","cloned","patterns","."]
code: def _pattern_permute(self, basic_pattern, options, basic_result):
      """pattern_permute takes a basic pattern and its result and clones
      the pattern according to the modifications described in the $options
      parameter. It returns a list of all cloned patterns."""
      patterns = [(basic_pattern, basic_result)]
  
      # rotations
      if "4" in options:
          res = patterns[-1][1]
          for i in range(4):
              patterns.append(
                  (
                      self._string_permute(
                          patterns[-1][0], ROTATION_MATRIX
                      ),
                      res,
                  )
              )
      # mirror
      if "M" in options:
          n = len(patterns)
          for pattern, res in patterns[:n]:
              patterns.append(
                  (self._string_permute(pattern, MIRROR_MATRIX), res)
              )
  
      # negate
      if "N" in options:
          n = len(patterns)
          for pattern, res in patterns[:n]:
              # Swap 0 and 1
              pattern = (
                  pattern.replace("0", "Z")
                  .replace("1", "0")
                  .replace("Z", "1")
              )
              res = 1 - int(res)
              patterns.append((pattern, res))
  
      return patterns
  
file_path: catboost/contrib/python/Pillow/py3/PIL/ImageMorph.py
imports: import re
  from .None import Image, _imagingmorph
label_desc: Use image node_id 6 for calling the LutBuilder obj's underlying member method code with example usage: obj._pattern_permute(basic_pattern, options, basic_result) and returns: patterns