Exemple #1
0
    def test_lumpy(self):
        lumpy = Lumpy.Lumpy()
        lumpy.restrict_class(Tests)
        lumpy.opaque_class(Tests)
        self.assertTrue(lumpy.is_opaque(Tests))

        lumpy.transparent_class(Tests)
        self.assertFalse(lumpy.is_opaque(Tests))

        lumpy.opaque_module(unittest)

        things_drawn = lumpy.object_diagram(loop=False)
        self.assertTrue(things_drawn > 200)

        things_drawn = lumpy.class_diagram(loop=False)
        self.assertTrue(things_drawn > 200)
Exemple #2
0
from swampy.Lumpy import *
import copy


lumpy = Lumpy()
lumpy.make_reference()


class Card(object):
    """Represents a Poker Card.
    """
    labels = ['straightflush', 'fourkind', 'fullhouse', 'flush',
            'straight', 'threekind', 'twopair', 'pair', 'highcard']


    def __init__(self, suit, rank):
        self.suit = suit
        self.rank = rank

class Rectangle(object):
    """Represents a Rectangle.

    attribute: width, height, cornner of Point object
    """


class Point(object):
    """Represents a Point with 2-D space.

    attribute: x, y
    """
#!/usr/bin/python

import swampy.Lumpy
lumpy = Lumpy.Lumpy()

# if you don't make a reference after instantiating
# Lumpy, the local variable lumpy is visible.  Even
# so, the Lumpy class is opaque by default, so we
# have to make it transparent.
lumpy.transparent_class(Lumpy.Lumpy)

lumpy.class_diagram()

from swampy.Lumpy import *
import copy

lumpy = Lumpy()
lumpy.make_reference()


class Rectangle(object):
    """Represents a Rectangle.

    attribute: width, height, cornner of Point object
    """


class Point(object):
    """Represents a Point with 2-D space.

    attribute: x, y
    """


def instantiate(constructor):
    """Instantiates a new object."""
    obj = constructor()
    lumpy.object_diagram()
    return obj


point = instantiate(Point)
Exemple #5
0
            d[c] += 1
    return d


def invert_dict(d):
    inv = dict()
    for key in d:
        val = d[key]
        if val not in inv:
            inv[val] = [key]
        else:
            inv[val].append(key)
    return inv


lumpy = Lumpy()
lumpy.make_reference()

empty = []

hist = histogram('parrot')
inverse = invert_dict(hist)

box = Rectangle()
box.width = 100.0
box.height = 200.0
box.corner = Point()
box.corner.x = 0.0
box.corner.y = 0.0

box2 = copy.copy(box)
from swampy.Lumpy import *
import copy


lumpy = Lumpy()
lumpy.make_reference()


class Rectangle(object):
    """Represents a Rectangle.

    attribute: width, height, cornner of Point object
    """


class Point(object):
    """Represents a Point with 2-D space.

    attribute: x, y
    """


def instantiate(constructor):
    """Instantiates a new object."""
    obj = constructor()
    lumpy.object_diagram()
    return obj

point = instantiate(Point)