:py:mod:`alhambra.fastreduce`
=============================

.. py:module:: alhambra.fastreduce


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   alhambra.fastreduce.FGlueList
   alhambra.fastreduce.FTileList
   alhambra.fastreduce._FastTileSet



Functions
~~~~~~~~~

.. autoapisummary::

   alhambra.fastreduce._fdg
   alhambra.fastreduce._ffakedouble_n
   alhambra.fastreduce._ffakesingle
   alhambra.fastreduce._ft_to_fta
   alhambra.fastreduce.ptins
   alhambra.fastreduce.is_2go_single_nn
   alhambra.fastreduce.gen_2go_single_ins
   alhambra.fastreduce.gen_2go_profile
   alhambra.fastreduce.is_2go_equiv
   alhambra.fastreduce.is_22go_equiv
   alhambra.fastreduce.fta_to_ft
   alhambra.fastreduce.isatamequiv
   alhambra.fastreduce.tilemerge
   alhambra.fastreduce._findpotentialtilemerges
   alhambra.fastreduce._findpotentialgluemerges
   alhambra.fastreduce._recfix
   alhambra.fastreduce._tilereduce
   alhambra.fastreduce._gluereduce
   alhambra.fastreduce._single_reduce_tiles
   alhambra.fastreduce._single_reduce_ends
   alhambra.fastreduce.reduce_tiles
   alhambra.fastreduce.reduce_ends



Attributes
~~~~~~~~~~

.. autoapisummary::

   alhambra.fastreduce.FTile
   alhambra.fastreduce.FTilesArray
   alhambra.fastreduce.TAU
   alhambra.fastreduce.uN
   alhambra.fastreduce.uI
   alhambra.fastreduce.uO
   alhambra.fastreduce.uB
   alhambra.fastreduce.uP
   alhambra.fastreduce.U_UNUSED
   alhambra.fastreduce.U_INPUT
   alhambra.fastreduce.U_OUTPUT
   alhambra.fastreduce.RSEL
   alhambra.fastreduce.FTI
   alhambra.fastreduce.HSEL
   alhambra.fastreduce.VSEL


.. py:data:: FTile

   

.. py:data:: FTilesArray

   

.. py:data:: TAU
   :value: 2

   

.. py:data:: uN
   :value: 0

   

.. py:data:: uI
   :value: 1

   

.. py:data:: uO
   :value: 2

   

.. py:data:: uB
   :value: 3

   

.. py:data:: uP
   :value: 4

   

.. py:class:: FGlueList(glues)


   .. py:method:: blankequiv()


   .. py:method:: iseq(equiv, a, b)


   .. py:method:: domerge(equiv, a, b, preserveuse=False)



.. py:data:: U_UNUSED

   

.. py:data:: U_INPUT
   :value: 1

   

.. py:data:: U_OUTPUT
   :value: 0

   

.. py:class:: FTileList(tiles, gluelist)



.. py:data:: RSEL
   :value: (2, 3, 0, 1)

   

.. py:data:: FTI
   :value: (1, 0, 1, 0)

   

.. py:function:: _fdg(dir, gs1, gs2)


.. py:function:: _ffakedouble_n(tn, sta, gluelist, outputonly=True, dir4=False, equiv=None)


.. py:data:: HSEL
   :value: ((1, 0, 5, 6), (2, 3, 4, 0))

   

.. py:data:: VSEL
   :value: ((1, 2, 0, 6), (0, 3, 4, 5))

   

.. py:function:: _ffakesingle(ftile, gluelist)


.. py:function:: _ft_to_fta(ftiles)


.. py:class:: _FastTileSet(tilesystem)


   .. py:method:: applyequiv(ts, equiv)


   .. py:method:: togluemergespec(ts, equiv)



.. py:function:: ptins(fts, equiv=None, tau=2)

   Calculate potential tile attachments to input neighborhoods


.. py:function:: is_2go_single_nn(fts, tn, un, equiv, tau=2, in2go=None, retall=False, also22go=False)


.. py:function:: gen_2go_single_ins(fts, tau=2)


.. py:function:: gen_2go_profile(fts, equiv=None, ins2go=None, also22go=False)


.. py:function:: is_2go_equiv(fts, equiv=None, ins2go=None, origsens=None)


.. py:function:: is_22go_equiv(fts, equiv=None, ins2go=None, orig22go=None)


.. py:function:: fta_to_ft(stiles, un, sel=None)


.. py:function:: isatamequiv(fts, equiv, initptins=None)


.. py:function:: tilemerge(fts, equiv, t1, t2, preserveuse=False)


.. py:function:: _findpotentialtilemerges(fts, equiv)


.. py:function:: _findpotentialgluemerges(fts, equiv)


.. py:function:: _recfix(fts, equiv, tp, initptins, check2go=False, ins2go=None, orig2go=None, orig22go=None, check22go=False, checkld=False, chain=None, preserveuse=False)


.. py:function:: _tilereduce(fts, equiv=None, check2go=False, initptins=None, check22go=False, checkld=False, preserveuse=False)


.. py:function:: _gluereduce(fts, equiv=None, check2go=False, check22go=False, checkld=False, initptins=None, preserveuse=False)


.. py:function:: _single_reduce_tiles(p)


.. py:function:: _single_reduce_ends(p)


.. py:function:: reduce_tiles(tileset, preserve=('s22', 'ld'), tries=10, threads=1, returntype='equiv', best=1, key=None, initequiv=None)

   Apply tile reduction algorithm, preserving some set of properties, and using a multiprocessing pool.

   :param tileset: The system to reduce.
   :type tileset: TileSet
   :param preserve: The properties to preserve.  Currently supported are 's1' for first order
                    sensitivity, 's2' for second order sensitivity, 's22' for two-by-two sensitivity,
                    'ld' for small lattice defects, and 'gs' for glue sense (to avoid spurious
                    hierarchical attachment).  Default is currently ('s22', 'ld').
   :type preserve: a tuple or list of strings, optional
   :param tries: The number of times to run the algorithm.
   :type tries: int, optional
   :param threads: The number of threads to use (using multiprocessing).
   :type threads: int, optional
   :param returntype: The type of object to return.  If 'equiv', returns an array of glue equivalences
                      (or list, if best != 1) that can be applied to the tileset with apply_equiv, or used
                      for further reduction.  If 'TileSet', return a TileSet with the equiv already applied
                      (or a list, if best != 1).
   :type returntype: 'TileSet' or 'equiv' (default 'equiv')
   :param best: The number of systems to return.  If 1, the result will be returned
                directly; if k > 1, a list will be returned of the best k results (per cmp);
                if k = None, a list of *all* results will be returned, sorted by cmp. (default 1)
   :type best: int or None, optional
   :param key: A comparison function for equivs, to sort the results. FIXME: documentation needed.
               Default (if None) here is to sort by number of glues in the system, regardless of number
               of tiles.
   :type key: function (ts, equiv1, equiv2) -> some number/comparable
   :param initequiv: If provided, the equivalence array to start from.  If None, start from the tileset without
                     any merged glues.
   :type initequiv: equiv

   :returns: **reduced** -- The reduced system/systems
   :rtype: single TileSet


.. py:function:: reduce_ends(tileset, preserve=('s22', 'ld'), tries=10, threads=1, returntype='equiv', best=1, key=None, initequiv=None)

   Apply end reduction algorithm, preserving some set of properties, and using a multiprocessing pool.

   :param tileset: The system to reduce.
   :type tileset: TileSet
   :param preserve: The properties to preserve.  Currently supported are 's1' for first order
                    sensitivity, 's2' for second order sensitivity, 's22' for two-by-two sensitivity,
                    'ld' for small lattice defects, and 'gs' for glue sense (to avoid spurious
                    hierarchical attachment).  Default is currently ('s22', 'ld').
   :type preserve: a tuple or list of strings, optional
   :param tries: The number of times to run the algorithm.
   :type tries: int, optional
   :param threads: The number of threads to use (using multiprocessing).
   :type threads: int, optional
   :param returntype: The type of object to return.  If 'equiv', returns an array of glue equivalences
                      (or list, if best != 1) that can be applied to the tileset with apply_equiv, or used
                      for further reduction.  If 'TileSet', return a TileSet with the equiv already applied
                      (or a list, if best != 1).
   :type returntype: 'TileSet' or 'equiv' (default 'equiv')
   :param best: The number of systems to return.  If 1, the result will be returned
                directly; if k > 1, a list will be returned of the best k results (per cmp);
                if k = None, a list of *all* results will be returned, sorted by cmp. (default 1)
   :type best: int or None, optional
   :param key: A comparison function for equivs, to sort the results. FIXME: documentation needed.
               Default (if None) here is to sort by number of glues in the system, regardless of number
               of tiles.
   :type key: function (ts, equiv1, equiv2) -> some number/comparable
   :param initequiv: If provided, the equivalence array to start from.  If None, start from the tileset without
                     any merged glues.
   :type initequiv: equiv

   :returns: **reduced** -- The reduced system/systems
   :rtype: single TileSet


