<commit_before>"""
Analysis tools for Topographica, other than plotting tools.

Configures the interface to the featuremapper and dataviews projects
and sets the appropriate Topographica-specific hooks.
"""

from topo.analysis.featureresponses import FeatureResponses, FeatureCurves,\
    FeatureMaps, ReverseCorrelation, MeasureResponseCommand, pattern_response,\
    topo_metadata_fn, StorageHook, get_feature_preference
from featuremapper.command import measure_response

import numpy as np

from dataviews.collector import Reference
from dataviews.options import channels, ChannelOpts
from dataviews.operation import cmap2rgb, operator, chain

import topo
from featuremapper.command import Collector
from topo.base.sheet import Sheet
from topo.base.projection import Projection
from topo.misc.ipython import RunProgress

from command import measure_cog


class SimRef(Reference):
    """
    A SimRef instance is installed on Collector to allow Topographica
    model elements to be referenced for collection.

    This is important to allow pickling and unpickling of Collectors
    that work correctly with Topographica in different execution
    environments (e.g. nodes of a cluster) and across different models
    without directly pickling the components (e.g. Sheets and
    Projections) themselves.

    More information about references can be found in the docstring of
    the dataviews.collector.Reference.
    """
    @property
    def resolved_type(self):
        if self.array_ref:
            return np.ndarray
        elif isinstance(self.obj, tuple):
            return Projection
        else:
            return Sheet

    def __init__(self, obj=None, array_ref=None):<commit_msg>Added testing comparisons for CFView, CFStack and imagen.Animation<commit_after>"""
Analysis tools for Topographica, other than plotting tools.

Configures the interface to the featuremapper and dataviews projects
and sets the appropriate Topographica-specific hooks.
"""

from topo.analysis.featureresponses import FeatureResponses, FeatureCurves,\
    FeatureMaps, ReverseCorrelation, MeasureResponseCommand, pattern_response,\
    topo_metadata_fn, StorageHook, get_feature_preference
from featuremapper.command import measure_response

import numpy as np

from dataviews.collector import Reference
from dataviews.options import channels, ChannelOpts
from dataviews.operation import cmap2rgb, operator, chain
from dataviews.testing import IPTestCase

import topo
from featuremapper.command import Collector
from topo.base.sheet import Sheet
from topo.base.projection import Projection
from topo.misc.ipython import RunProgress

from command import measure_cog

from topo.base.sheetview import CFView, CFStack
from imagen import Animation

class TopoIPTestCase(IPTestCase):

    def __init__(self, *args, **kwargs):
        super(TopoIPTestCase, self).__init__(*args, **kwargs)
        self.addTypeEqualityFunc(CFView,   self.compare_cfviews)
        self.addTypeEqualityFunc(CFStack,   self.compare_cfstack)
        self.addTypeEqualityFunc(Animation,   self.compare_animation)

    def compare_cfviews(self, view1, view2, msg):
        self.compare_sheetviews(view1, view2, msg)

    def compare_cfstack(self, view1, view2, msg):
        self.compare_sheetstack(view1, view2, msg)

    def compare_animation(self, view1, view2, msg):
        self.compare_sheetstack(view1, view2, msg)



class SimRef(Reference):
    """
    A SimRef instance is installed on Collector to allow Topographica
    model elements to be referenced for collection.

    This is important to allow pickling and unpickling of Collectors
    that work correctly with Topographica in different execution
    environments (e.g. nodes of a cluster) and across different models
    without directly pickling the components (e.g. Sheets and
    Projections) themselves.

    More information about references can be found in the docstring of
    the dataviews.collector.Reference.
    """
    @property
    def resolved_type(self):
        if self.array_ref:
            return np.ndarray
        elif isinstance(self.obj, tuple):
            return Projection
        else:
            return Sheet

    def __init__(self, obj=None, array_ref=None):
{'fraction_non_alphanumeric': 0.056068133427963095, 'fraction_numerical': 0.0033120416370948664, 'mean_word_length': 4.07563025210084, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4522002', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1126, 'n_words': 398}