예제 #1
0
    def test_default(self):
        info = infos.encode(["other", "one", "two"], defcat=0)

        self.assertEqual(0, info("other"))
        self.assertEqual(1, info("one"))
        self.assertEqual(2, info("two"))
        self.assertEqual(0, info("stuff"))
        self.assertEqual(0, info("more"))
예제 #2
0
    def test(self):
        info = infos.encode(["zero", "one", "two"])

        self.assertEqual(0, info("zero"))
        self.assertEqual(1, info("one"))
        self.assertEqual(2, info("two"))
        self.assertEqual(3, info("stuff"))
        self.assertEqual(3, info("more"))
예제 #3
0
def _create_plot_component():
    red = util.Color(255, 0, 0, 255)
    green = util.Color(0, 255, 0, 255)
    blue = util.Color(0, 0, 255, 255)
    purple = util.Color(125, 0, 255, 255)
    white = util.Color(255, 255, 255, 255)
    black = util.Color(0, 0, 0, 255)
    clear = util.Color(0, 0, 0, 0)

    with Timer("Loeading") as arTimer:
        #glyphs = npg.load_csv("../data/circlepoints.csv", 1, 2, 3, 4)
        #glyphs = npg.load_hdf("../data/CensusTracts.hdf5", "__data__", "LAT", "LON")
        glyphs = npg.load_hdf("../data/tweets-subset.hdf",
                              "test",
                              "longitude",
                              "latitude",
                              vc="lang_primary")

    screen = (800, 600)
    ivt = util.zoom_fit(screen, glyphs.bounds())

    with Timer("Abstract-Render") as arTimer:
        image = core.render(
            glyphs, infos.encode(["Arabic", "English", "Turkish", "Russian"]),
            npg.PointCountCategories(),
            npg.Spread(2) + categories.HDAlpha(
                [red, blue, green, purple, black], alphamin=.3, log=True),
            screen, ivt)
#      image = core.render(glyphs,
#                          infos.valAt(4,0),
#                          npg.PointCount(),
#                          npg.Spread(1) + numeric.BinarySegment(white, black, 1),
#                          screen,
#                          ivt)

# Create a plot data object and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", image)

    # Create the plot
    plot = Plot(pd)
    img_plot = plot.img_plot("imagedata")[0]

    # Tweak some of the plot properties
    plot.title = "Abstract Rendering"
    plot.padding = 50

    return plot
예제 #4
0
def _create_plot_component():
    red = util.Color(255,0,0,255)
    green = util.Color(0,255,0,255)
    blue = util.Color(0,0,255,255)
    purple = util.Color(125,0,255,255)
    white = util.Color(255,255,255,255)
    black = util.Color(0,0,0,255)
    clear = util.Color(0,0,0,0)
    
    with Timer("Loeading") as arTimer:   
        #glyphs = npg.load_csv("../data/circlepoints.csv", 1, 2, 3, 4)
        glyphs = npg.load_hdf("../data/CensusTracts.hdf5", "__data__", "LAT", "LON")
        #glyphs = npg.load_hdf("../data/tweets-subset.hdf", "test", 
        #                      "longitude", "latitude", vc="lang_primary")

    screen = (800,600)
    ivt = util.zoom_fit(screen,glyphs.bounds())

    with Timer("Abstract-Render") as arTimer:   
      image = core.render(glyphs, 
                          infos.encode(["Arabic","English","Turkish","Russian"]),
                          npg.PointCountCategories(),
                          npg.Spread(2) + categories.HDAlpha([red, blue, green, purple, black], alphamin=.3, log=True),
                          screen,
                          ivt)
#      image = core.render(glyphs, 
#                          infos.valAt(4,0),
#                          npg.PointCount(),
#                          npg.Spread(1) + numeric.BinarySegment(white, black, 1),
#                          screen,
#                          ivt)

    # Create a plot data object and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", image)

    # Create the plot
    plot = Plot(pd)
    img_plot = plot.img_plot("imagedata")[0]

    # Tweak some of the plot properties
    plot.title = "Abstract Rendering"
    plot.padding = 50
    
    return plot