print tree

    # boxes defined by lower corner followed by width and height. So
    # np.array( [[1,2.],[1,3]] ) is anchored at (1,2), has width 1 and
    # height 3. Definition extends for higher dimensions (row 0 == anchor,
    # row 1 == size in j'th dimension).
    all_data = np.loadtxt( '../sandbox/squareNoiseHenonLong.txt' )
    data = all_data[:npts,:2]
    noise = all_data[:npts,2]
    print "Read data and noise arrays"
    # print "data", data
    # print ""
    # print "noise", noise
    # print ""
    FR = FiniteRepresentation( data, tree, noise )
    #FR.add_error_boxes()
    # print "Constructed tree and error boxes"

    FR.construct_mvm_simple()
    FR.graph_mis()
    FR.tree.remove( list(set(range(FR.tree.tree.size))-set(FR.mis)) )

    # convert nodes to integers starting at 0
    H = nx.convert_node_labels_to_integers( FR.mvm.graph, first_label=0 )
    
    # True Henon
    # our tree, mapper, enclosure
    tree = Tree(box,full=True)
    m = HenonMapper()
    ce = CombEnc(tree,m)
def test_finite_rep_henon(depth, box, npts, plot=False, fpath="../sandbox/henon_test"):

    tree = BoxTree(box, depth)

    # boxes defined by lower corner followed by width and height. So
    # np.array( [[1,2.],[1,3]] ) is anchored at (1,2), has width 1 and
    # height 3. Definition extends for higher dimensions (row 0 == anchor,
    # row 1 == size in j'th dimension).
    all_data = np.loadtxt("../sandbox/squareNoiseHenonLong.txt")
    data = all_data[:npts, :2]
    noise = all_data[:npts, 2]
    print "Read data and noise arrays"
    # print "data", data
    # print ""
    # print "noise", noise
    # print ""
    FR = FiniteRepresentation(data, tree, noise)
    # FR.add_error_boxes()
    # print "Constructed tree and error boxes"

    FR.construct_mvm_simple()
    # FR.construct_mvm_expansion()
    print "MVM done!"

    FR.graph_mis()
    print "Computed maximal invariant set (SCC)!"
    print "len(FR.mis) = ", len(FR.mis)

    # if len( FR.mis ) != len( FR.mvm ):
    #     print "There are", len( FR.mvm ) - len( FR.mis ), "transient nodes."
    #     FR.trim_graph()
    #     print "Trimmed graph down the maximal invariant set (SCC)."

    if plot:
        print "Plotting boxes... "
        fig = FR.show_boxes()
        fig = FR.show_error_boxes(color="r", fig=fig)
    print "done with FR @ depth", depth
    print ""

    fname = fpath + dot + "FR" + dot + str(depth) + dot + str(npts)
    FR.write_mvm(fname + ".dot")
    FR.pickle_tree(fname + ".pkl")