Beispiel #1
0
def test_popkey_1():
    """test_popkey_1, Basic usage test of popkey
    """
    dct = dict(a=1, b=2, c=3)
    nt.assert_equal(genutils.popkey(dct, "a"), 1)
    nt.assert_equal(dct, dict(b=2, c=3))
    nt.assert_equal(genutils.popkey(dct, "b"), 2)
    nt.assert_equal(dct, dict(c=3))
    nt.assert_equal(genutils.popkey(dct, "c"), 3)
    nt.assert_equal(dct, dict())
Beispiel #2
0
def test_popkey_1():
    """test_popkey_1, Basic usage test of popkey
    """
    dct = dict(a=1, b=2, c=3)
    nt.assert_equal(genutils.popkey(dct, "a"), 1)
    nt.assert_equal(dct, dict(b=2, c=3))
    nt.assert_equal(genutils.popkey(dct, "b"), 2)
    nt.assert_equal(dct, dict(c=3))
    nt.assert_equal(genutils.popkey(dct, "c"), 3)
    nt.assert_equal(dct, dict())
Beispiel #3
0
    def __plot_ps(self, plot_method, *items, **keyw):
        """Wrapper for plot/splot/replot, with processing of hardcopy options.

        For internal use only."""

        # Filter out PostScript options which will crash the normal plot/replot
        psargs = {
            'filename': None,
            'mode': None,
            'eps': None,
            'enhanced': None,
            'color': None,
            'solid': None,
            'duplexing': None,
            'fontname': None,
            'fontsize': None,
            'debug': 0
        }

        for k in psargs.keys():
            if keyw.has_key(k):
                psargs[k] = keyw[k]
                del keyw[k]

        # Filter out other options the original plot doesn't know
        hardcopy = popkey(keyw, 'hardcopy', psargs['filename'] is not None)
        titles = popkey(keyw, 'titles', 0)

        # the filename keyword should control hardcopy generation, this is an
        # override switch only which needs to be explicitly set to zero
        if hardcopy:
            if psargs['filename'] is None:
                raise ValueError, \
                      'If you request hardcopy, you must give a filename.'

            # set null output so nothing goes to screen. hardcopy() restores output
            self('set term dumb')
            # I don't know how to prevent screen output in Windows
            if os.name == 'posix':
                self('set output "/dev/null"')

        new_items = zip_items(items, titles)
        # plot_method is either plot or replot from the original Gnuplot class:
        plot_method(self, *new_items, **keyw)

        # Do hardcopy if requested
        if hardcopy:
            if psargs['filename'].endswith('.eps'):
                psargs['eps'] = 1
            self.hardcopy(**psargs)
Beispiel #4
0
    def __plot_ps(self, plot_method, *items, **keyw):
        """Wrapper for plot/splot/replot, with processing of hardcopy options.

        For internal use only."""

        # Filter out PostScript options which will crash the normal plot/replot
        psargs = {
            "filename": None,
            "mode": None,
            "eps": None,
            "enhanced": None,
            "color": None,
            "solid": None,
            "duplexing": None,
            "fontname": None,
            "fontsize": None,
            "debug": 0,
        }

        for k in psargs.keys():
            if keyw.has_key(k):
                psargs[k] = keyw[k]
                del keyw[k]

        # Filter out other options the original plot doesn't know
        hardcopy = popkey(keyw, "hardcopy", psargs["filename"] is not None)
        titles = popkey(keyw, "titles", 0)

        # the filename keyword should control hardcopy generation, this is an
        # override switch only which needs to be explicitly set to zero
        if hardcopy:
            if psargs["filename"] is None:
                raise ValueError, "If you request hardcopy, you must give a filename."

            # set null output so nothing goes to screen. hardcopy() restores output
            self("set term dumb")
            # I don't know how to prevent screen output in Windows
            if os.name == "posix":
                self('set output "/dev/null"')

        new_items = zip_items(items, titles)
        # plot_method is either plot or replot from the original Gnuplot class:
        plot_method(self, *new_items, **keyw)

        # Do hardcopy if requested
        if hardcopy:
            if psargs["filename"].endswith(".eps"):
                psargs["eps"] = 1
            self.hardcopy(**psargs)
Beispiel #5
0
def test_popkey_3():
    """test_popkey_3, Tests to see that popkey calls returns the correct value
    and that the key/value was removed from the dict.
    """
    dct = dict(a=1, b=2, c=3)
    nt.assert_equal(genutils.popkey(dct, "A", 13), 13)
    nt.assert_equal(dct, dict(a=1, b=2, c=3))
    nt.assert_equal(genutils.popkey(dct, "B", 14), 14)
    nt.assert_equal(dct, dict(a=1, b=2, c=3))
    nt.assert_equal(genutils.popkey(dct, "C", 15), 15)
    nt.assert_equal(dct, dict(a=1, b=2, c=3))
    nt.assert_equal(genutils.popkey(dct, "a"), 1)
    nt.assert_equal(dct, dict(b=2, c=3))
    nt.assert_equal(genutils.popkey(dct, "b"), 2)
    nt.assert_equal(dct, dict(c=3))
    nt.assert_equal(genutils.popkey(dct, "c"), 3)
    nt.assert_equal(dct, dict())
Beispiel #6
0
def test_popkey_3():
    """test_popkey_3, Tests to see that popkey calls returns the correct value
    and that the key/value was removed from the dict.
    """
    dct = dict(a=1, b=2, c=3)
    nt.assert_equal(genutils.popkey(dct, "A", 13), 13)
    nt.assert_equal(dct, dict(a=1, b=2, c=3))
    nt.assert_equal(genutils.popkey(dct, "B", 14), 14)
    nt.assert_equal(dct, dict(a=1, b=2, c=3))
    nt.assert_equal(genutils.popkey(dct, "C", 15), 15)
    nt.assert_equal(dct, dict(a=1, b=2, c=3))
    nt.assert_equal(genutils.popkey(dct, "a"), 1)
    nt.assert_equal(dct, dict(b=2, c=3))
    nt.assert_equal(genutils.popkey(dct, "b"), 2)
    nt.assert_equal(dct, dict(c=3))
    nt.assert_equal(genutils.popkey(dct, "c"), 3)
    nt.assert_equal(dct, dict())