def __init__(self, name, highlight_feature):
     Dog.__init__(self, name)
     self.highlight_feature = highlight_feature  # Instance memeber of the GoldenRetriever child class instances
     Dog.add_trick(
         self, "Retrieve shot game")  # Calls add_trick from base class dog
     self.add_trick(
         "Zoomies")  # Calls add_trick from child class GoldenRetriever
Exemplo n.º 2
0
    def __init__(self, mqtt, dao, publisher):
        self.mqtt = mqtt
        self.publisher = publisher
        self.dao = dao
        self.dog = Dog(self.dao, self.publisher)
        self.mqttClients = dict()

        self.mqtt.on_connect = self.on_connect
        self.mqtt.on_message = self.on_message

        self.actions = {
            0: self.dao.getBlueprint_using_id,
            #
            10: self.dao.createEnvironment,
            11: self.dao.updateEnvironment,
            12: self.dao.deleteEnvironment,
            #
            23: self.dao.applyDeviceCommand,
            24: self.dao.setAppliedDeviceCommand,
            #
            30: self.dao.createScene,
            31: self.dao.updateScene,
            32: self.dao.deleteScene,
            33: self.dao.applySceneCommands,
            #
            40: self.dao.createUser,
            41: self.dao.updateUser,
            42: self.dao.deleteUser,
            43: self.dao.login,
        }
Exemplo n.º 3
0
def getXDoGImg(image, sigma=1.0, k_sigma=3.0):
    print "XDoG start"
    dog = Dog(image)
    XDoGImg = cv2.cvtColor(np.uint8(dog.xdogGrayTransform(dog.xdog(sigma, k_sigma))), cv2.COLOR_GRAY2RGB)
    saveImg("XDoGImg.png", XDoGImg)
    print "XDoG finish"
    return XDoGImg
Exemplo n.º 4
0
    def test_set_and_get_species_dog(self):

        bobby = Dog("Bobby")
        bobby.set_species("Woofer")

        self.assertEqual(bobby.get_species(), "Woofer")
        self.assertEqual(self.bob.get_species(), "Dog")
        self.assertEqual(bobby.species, "Woofer")
Exemplo n.º 5
0
    def get_dogs(self, dogEls):
        '''
        Scrapes the dog information and returns a list of dog objects.
        '''
        dogs = []
        #Easier to calculate fin position than scrape it.
        dogCounter = 0
        
        for d in dogEls:
            dogElsChildren = d.getchildren()
            dogInfoCounter = 0
            dog = Dog()

            for dc in dogElsChildren:
                dcc = dc.getchildren()
                if dcc != []:
                    dogInfoCounter += 1
                    
                    if dcc[0].tag == 'a' and dcc[0].getchildren()[0].text != None:
                        dog.name = dcc[0].getchildren()[0].text.strip()
                        dogCounter += 1
                        dog.fin = "Fin: " + str(dogCounter)
                                
                    if dcc[0].tag == 'strong':
                        #Ignore table headers
                        if dcc[0].text.strip() == 'Greyhound' or \
                           dcc[0].text.strip() == 'Trap' or \
                           dcc[0].text.strip() == 'SP' or \
                           dcc[0].text.strip() == 'Time/Sec.' or \
                           dcc[0].text.strip() == 'None':
                            break
                            
                        if dogInfoCounter == 2:
                            dog.trap = dcc[0].text.strip()
                            
                        if dogInfoCounter == 3:
                            dog.sp = dcc[0].text.strip()
                            
                        if dogInfoCounter == 4:
                            dog.timeSec = dcc[0].text.strip()
                            
                        if dogInfoCounter == 5:
                            #Time distance and bracket is here
                            tdbSplit = dcc[0].text.strip().split(' (')
                            dog.timeDist = tdbSplit[0].strip()
                            try:
                                dog.bracket = tdbSplit[1].strip()\
                                    .replace(')', '')
                            except IndexError:
                                dog.bracket = "None"
                                
                            #Get the comment
                            dog.comment = self.get_comment(dc)
                            
                            dogs.append(dog)
        return dogs
Exemplo n.º 6
0
def main():
    home = Home()
    dog1 = Dog()
    dog2 = Dog()
    cat = Cat()

    home.adopt_pet(dog1)
    home.adopt_pet(cat)
    home.adopt_pet(dog2)
    home.make_all_sounds()
    home.adopt_pet(dog2)
Exemplo n.º 7
0
def generate_dataset(
    N=100,
    sigma=0.1,
    mu=0,
    balanced_sample=True,  # equal number of each class
    p=[1. / 5] * 5,  # for multinomial distribution of classes
    datapath="/home/joel/datasets/csi5138-img/dataset1"
):  # do not add trailing /

    for i in range(N):
        if balanced_sample:
            c = i % 5
        else:
            c = np.random.multinomial(1, p)  # choose class from distribution p
            c = np.argmax(c)
        # construct vector of N(mu, sigma**2)
        var = sigma * np.random.randn(5) + mu
        # no switch statement in Python?#yes noswitch statement in python
        if c == 0:
            obj = Dog(*var)
        elif c == 1:
            obj = Truck(*var)
        elif c == 2:
            obj = Airplane(*var)
        elif c == 3:
            obj = Person(*var)
        else:
            obj = Frog(*var)

        obj.generate(datapath, i)
def prob_page158():
    my_dog = Dog('Willie', 8)
    print(f"Hi doggie named: {my_dog.name}")
    my_dog.sit()
    my_dog.sit()
    my_dog.roll_over()
    my_dog.diagnostic()
	def constructTree(self):
		#Read next item from file. If theere are no more items or next
		#item is marker, then return
		line = self.file.readline().split(',')
		if line == [''] or line == ["-1\n"] or line==["-1"]:
			return

		#Else create node with this item and recur for children
		name = line[0].strip()
		color = line[1].strip()

		node = Dog(name, color);
		node.dam = self.constructTree()
		node.sire = self.constructTree()
		return node
Exemplo n.º 10
0
    def constructTree(self):
        #Read next item from file. If theere are no more items or next
        #item is marker, then return
        line = self.file.readline().split(',')
        if line == [''] or line == ["-1\n"] or line == ["-1"]:
            return

        #Else create node with this item and recur for children
        name = line[0].strip()
        color = line[1].strip()

        node = Dog(name, color)
        node.dam = self.constructTree()
        node.sire = self.constructTree()
        return node
Exemplo n.º 11
0
    def get_animal(self, animal_type):
        """Factory method for the Animal objects.
	
		Args:
			animal_type: instance of a str to identify
				the type.

		Returns:
			Initialised animal object.
		"""
        if animal_type is not None and type(animal_type) == str:
            animal_type = animal_type.lower()

        if animal_type is None:
            return NullAnimal()
        elif animal_type == "duck":
            self.__factory_objects += 1
            return Duck()
        elif animal_type == "dog":
            self.__factory_objects += 1
            return Dog()
        elif animal_type == "cat":
            self.__factory_objects += 1
            return Cat()
        else:
            return NullAnimal()
Exemplo n.º 12
0
 def __init__(self):
     # 初始化  3  条狗和  2  个人,随机生成一个判断轮次优先的  key
     for idx in range(self.__dog_num):
         self.__dog_list.append(Dog(idx + 1))
     for idx in range(self.__human_num):
         self.__human_list.append(Human(idx + 1))
     self.__key = random.randint(1, 1001)
Exemplo n.º 13
0
def main():
    home = Home()
    dog1 = Dog()
    dog2 = Dog()
    cat = Cat()
    

    dog1 = Dog("Rex", "barks")
    cat1 = Cat("Stormy", " meows")
    home.Adopt_pets(dog1)
    home.Adopt_pets(cat)
    home.Adopt_pets(dog2)
    home.makeAllSounds()
    print(home.pets[0].name)
    print(home.pets[1].name)
    
Exemplo n.º 14
0
 def load_csv(self):
     f = '/home/luizf/anaconda3/python_learning/simple-mvc/dogs.csv'
     with open(f, newline='') as csvfile:
         spamreader = csv.reader(csvfile, delimiter=',')
         for row in spamreader:
             dog = Dog(row[0], row[1])
             self.dogs.append(dog)
Exemplo n.º 15
0
    def __ok_name_button_on_click(self):
        """button click event of ok_name_button"""
        s = self.__name_entry.get()
        if s != "":
            self.__dog = Dog(s)
            self.__text_label.configure(text=self.__dog.bark())

            # show components:
            self.__x_label.lift()
            self.__first_number_entry.lift()
            self.__second_number_entry.lift()
            self.__ok_calc_button.lift()
            self.__go_racing_button.lift()
            self.__give_food_button.lift()
            self.__give_drink_button.lift()
        else:
            self.__text_label.configure(text="Graag een naam van je hond invoeren.")

            # hide components:
            self.__x_label.lower()
            self.__first_number_entry.lower()
            self.__second_number_entry.lower()
            self.__ok_calc_button.lower()
            self.__go_racing_button.lower()
            self.__give_food_button.lower()
            self.__give_drink_button.lower()
Exemplo n.º 16
0
def show_dog():
    pygame.init()
    screen = pygame.display.set_mode((1200, 600))
    pygame.display.set_caption("Show Dog")

    my_dog = Dog(screen)

    while True:
        """响应按键和鼠标事件"""
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

        screen.fill((0, 255, 0))
        my_dog.blitme()

        pygame.display.flip()
Exemplo n.º 17
0
def read_dogstxt(fn):
    doglist = []
    with open(fn) as f:
        for line in f:
            attrs = line.strip().split(',')
            d = Dog(attrs[0], attrs[1], attrs[2])
            doglist.append(d)
        return doglist
Exemplo n.º 18
0
class DogTest(unittest.TestCase):
    def setUp(self):
        self.default_dog = Dog()
        self.custom_dog = Dog(name='Mickey', species='Lab')

    def test_defaults(self):
        self.assertEqual(self.default_dog.name, 'Spot')
        self.assertEqual(self.default_dog.species, 'Dalmation')
        self.assertEqual(self.custom_dog.name, 'Mickey')
        self.assertEqual(self.custom_dog.species, 'Lab')

    def test_bark(self):
        self.assertEqual(self.default_dog.bark(), 'Woof!')
        self.assertEqual(self.custom_dog.bark(), 'Woof!')

    def test_run(self):
        self.assertEqual(self.default_dog.run(),
                         'Vroom!')  # Doesn't work! Printing is a side effect
Exemplo n.º 19
0
def main():
    objects = []
    
    dog = Dog()
    objects.append(Adapter(dog, dict(make_noise=dog.bark)))
    cat = Cat()
    objects.append(Adapter(cat, dict(make_noise=cat.meow)))

    for obj in objects:
        print("A {0} goes {1}".format(obj.name, obj.make_noise()))
Exemplo n.º 20
0
    def read():
        dogs = []
        file = open('dogs.data', 'r')
        if file.readline() == "name,breed,age\n":
            for line in file:
                values = line.strip('\n').split(',')
                dogs.append(Dog(values[0], values[1], values[2]))
        file.close()

        return dogs
Exemplo n.º 21
0
def create_pack(game_settings, screen, dogs):
    """Create pack of dogs."""
    # Create dog and decision number of dogs.
    # Distance between dogs.
    dog = Dog(game_settings, screen)
    dog_height = dog.rect.height
    available_space_y = game_settings.screen_height
    number_dogs_y = 3
    number_rows = 5

    # Create pack of dogs.
    for row_number in range(number_rows):
        for dog_number in range(number_dogs_y):
            # Create dog and placing it in row.
            dog = Dog(game_settings, screen)
            dog.y = dog_height + 2 * dog_height * dog_number
            dog.rect.y = dog.y
            dog.rect.x = 2 * dog.rect.width * row_number + 1000
            dogs.add(dog)
Exemplo n.º 22
0
 def __init__(self, p=2, d=3):
     # 生成p个人,d条狗
     self.people = []
     for i in range(1, p + 1):
         self.people.append(Human(i))
     self.dogs = []
     for i in range(1, d + 1):
         self.dogs.append(Dog(i))
     # 随机决定比赛顺序
     self.human_first = bool(randint(0, 1))
Exemplo n.º 23
0
def test():
    date1 = date(1999, 5, 5)
    date2 = date(2000, 5, 5)
    date3 = date(2002, 5, 1)
    date4 = date(2022, 5, 1)
    date5 = date(2022, 5, 2)
    dog1 = Dog("firulais", date1, "galgo")
    dog2 = Dog("cholo", date2, "pitbull")
    dogs = [dog1, dog2]
    owner1 = Owner("Diego", "123456789-1", [dog1, dog2])
    dog3 = Dog("cleo", date3, "golden retriever")
    owner1.add_dog(dog3)
    dogs = owner1.dogs
    race1 = Race(date4, dogs)
    race2 = Race(date5, dogs)
    races = [race1, race2]
    event1 = Event(date4, date5, "Santiago", races)
    race1.run_race()
    positions_table = race1.make_positions_table()
    print(positions_table)
Exemplo n.º 24
0
    def test_dog_walking(self):

        bobby = Dog("Bobby")
        bobby.set_legs(6)
        self.assertEqual(bobby.speed, 0)
        bobby.walk()
        self.assertEqual(bobby.speed, 1.2)
Exemplo n.º 25
0
def basics():
    # failing to instantiate an class with '@abstractmothods'
    # animal = Animal()
    # print(animal)

    # instantiate Dog
    default_dog = Dog()
    snoop_dog = Dog("Snoop", "A dog that smokes a lot", 2)
    booze_dog = Bernard("Johnnie Walker",
                        "St Bernard with the iconic barrel",
                        barrelvolume=1)

    # instantiate Bird
    default_bird = Bird()
    bird_of_prey = Bird("Bird-of-Prey", "An agile Klingon starship")

    # print results
    print(default_dog)
    print(snoop_dog)
    print(booze_dog)
    print(default_bird)
    print(bird_of_prey)
Exemplo n.º 26
0
def main():
    a = Animal()
    d = Dog()
    c = Cat()
    d.speak()
    c.speak()
    c.sleep()
    d.sleep()
    a.sleep()
Exemplo n.º 27
0
    def __init__(self):
        """Initialize the game, and create game resources."""
        pygame.init()
        self.settings = Settings()

        # Set the window size and title bar text
        # Windowed
        self.screen = pygame.display.set_mode(
            (self.settings.screen_width, self.settings.screen_height))
        # Full screen
        # self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
        # self.settings.screen_width = self.screen.get_rect().width
        # self.settings.screen_height = self.screen.get_rect().height
        pygame.display.set_caption("Play Ball!")

        # Create an instance to store game statistics.
        self.stats = GameStats(self)

        self.bear = Bear(self)
        self.balls = pygame.sprite.Group()
        self.dog = Dog(self)

        # Make the Play button.
        self.play_button = Button(self, "Play")
Exemplo n.º 28
0
def get_all():
    conn = sqlite3.connect("sqlite3/database.db")
    query = conn.cursor()

    sql = "SELECT * FROM dogs"

    if (query.execute(sql)):
        rows = query.fetchall()
        dogs_list = [Dog(row[0], row[1], row[2]) for row in rows]
        query.close()
        conn.commit()
        conn.close()
        return dogs_list
    else:
        raise Exception("Some error")
Exemplo n.º 29
0
def run_game():
    '''
    Initialize pygame ,
    create a screen object
    (window screen size & window caption) & settings
    '''
    pygame.init()
    dc_settings = Settings()  #Object of Settings() class
    screen = pygame.display.set_mode(
        (dc_settings.screen_width, dc_settings.screen_height
         ))  #set screen size by passing in Settings width & height attributes
    pygame.display.set_caption("Dog Catch")

    dog = Dog(dc_settings, screen)
    background = Background()
    ballx = Group()
    gf.create_ballx(dc_settings, screen, ballx)

    #Gmme main loop
    while True:
        gf.check_events(dc_settings, screen, dog)
        dog.update()
        gf.update_balls(screen, dc_settings, ballx, dog)
        gf.update_screen(dc_settings, background, screen, dog, ballx)
Exemplo n.º 30
0
def main():
    ob4a = Animal()
    ob4d = Dog()
    ob4c = Cat()
    ob4a.speak()
    ob4d.speak()
    ob4c.speak()
    ob4a.sleep()
    ob4d.sleep()
    ob4c.sleep()
Exemplo n.º 31
0
def main():
    animal = Animal()
    dog = Dog()
    cat = Cat()
    
    animal.speak()
    dog.speak()
    cat.speak()

    animal.sleep()
    dog.sleep()
    cat.sleep()
Exemplo n.º 32
0
def run_game():
    pygame.init()#initial pygame
    game_settings=Settings()
    screen=pygame.display.set_mode((game_settings.screen_width,game_settings.screen_height))#set the size of the window to 800*600
    dog=Dog(screen,game_settings)
    bullets=Group()
    aliens=Group()
    gf.create_fleet(game_settings,screen,aliens)
    pygame.display.set_caption("Time Collection")#set title
    time_before=time.time()
    while True:
        time_now=time.time()
        if time_now-time_before>=2:
            gf.create_fleet(game_settings,screen,aliens)
            time_before=time.time()
        
        gf.clickevent(dog,screen,game_settings,bullets)
        gf.refleshscreen(screen,dog,game_settings,bullets,aliens)
Exemplo n.º 33
0
def main():
    a = Animal()
    d = Dog()
    c = Cat()
    array = ["An Animal", "A Dog", "A Cat"]
    for i in range(0, len(array)):
        print("Making " + array[i])
    a.speak()
    d.speak()
    c.speak()
    a.sleep()
    d.sleep()
    c.sleep()
Exemplo n.º 34
0
class Gui(Frame):
    """class gui for creating UI frame"""

    __colors = ["white", "black", "red", "yellow", "green", "cyan", "blue", "magenta", "orange", "brown", "pink", "grey"]

    def __init__(self, parent):
        """initialize gui itself"""
        Frame.__init__(self, parent, background="white")
        self.parent = parent
        self.parent.title("Test Gui")
        self.pack(fill=BOTH, expand=1)

        self.__dog = Dog
        self.__name_entry = MaxLengthEntry
        self.__first_number_entry = IntegerEntry
        self.__second_number_entry = IntegerEntry
        self.__text_label = Label
        self.__x_label = Label
        self.__ok_calc_button = Button
        self.__go_racing_button = Button
        self.__give_food_button = Button
        self.__give_drink_button = Button

        self.__center_window()
        self.__init_ui()

    def __center_window(self):
        """define position and size of gui"""
        w = 500
        h = 300

        sw = self.parent.winfo_screenwidth()
        sh = self.parent.winfo_screenheight()

        x = (sw - w) / 2
        y = (sh - h) / 2
        self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))

    def __init_ui(self):
        """initialize UI components"""

        # button "Wijzig achtergrondskleur"
        change_button = Button(self.parent, text="Wijzig achtergrondskleur", command=self.__change_button_on_click)
        change_button.place(x=50, y=50)

        # entry (textbox) for dog's name input
        self.__name_entry = MaxLengthEntry(self.parent, maxlength=30, width=30)
        self.__name_entry.place(x=50, y=104)

        # button "OK" for admitting dog's name input
        ok_name_button = Button(self.parent, text="OK", command=self.__ok_name_button_on_click, width=10)
        ok_name_button.place(x=300, y=100)

        # label for showing text to user
        self.__text_label = Label(self.parent, text="Hoe heet je hond?", background="white", wraplength=400)
        self.__text_label.place(x=50, y=204)

        # label "X" between entries for input numbers
        self.__x_label = Label(self.parent, text="X", background="white")
        self.__x_label.place(x=428, y=54)
        self.__x_label.lower()

        # entry for first number input
        self.__first_number_entry = IntegerEntry(self.parent, width=2)
        self.__first_number_entry.place(x=400, y=54)
        self.__first_number_entry.lower()

        # entry for second number input
        self.__second_number_entry = IntegerEntry(self.parent, width=2)
        self.__second_number_entry.place(x=450, y=54)
        self.__second_number_entry.lower()

        # button "OK, reken!" for making dog to do math
        self.__ok_calc_button = Button(self.parent, text="OK, reken!", command=self.__ok_math_button_on_click, width=10)
        self.__ok_calc_button.place(x=400, y=100)
        self.__ok_calc_button.lower()

        # button "Ga rennen!" for making dog to go racing
        self.__go_racing_button = Button(self.parent, text="Ga rennen!", command=self.__go_racing_button_on_click, width=10)
        self.__go_racing_button.place(x=200, y=150)
        self.__go_racing_button.lower()

        # button "Eten!" for giving food to dog
        self.__give_food_button = Button(self.parent, text="Eten!", command=self.__give_food_button_on_click, width=10)
        self.__give_food_button.place(x=300, y=150)
        self.__give_food_button.lower()

        # button "Drinken!" for giving drink to dog
        self.__give_drink_button = Button(self.parent, text="Drinken!", command=self.__give_drink_button_on_click, width=10)
        self.__give_drink_button.place(x=400, y=150)
        self.__give_drink_button.lower()

    def __change_button_on_click(self):
        """button click event of change_button"""
        color = self.__random_color(self["background"])
        self.configure(background=color)
        self.__text_label.configure(background=color)
        self.__x_label.configure(background=color)
        if color == "black":
            self.__text_label.configure(foreground="white")
            self.__x_label.configure(foreground="white")
        else:
            self.__text_label.configure(foreground="black")
            self.__x_label.configure(foreground="black")
        print(color)

    def __ok_name_button_on_click(self):
        """button click event of ok_name_button"""
        s = self.__name_entry.get()
        if s != "":
            self.__dog = Dog(s)
            self.__text_label.configure(text=self.__dog.bark())

            # show components:
            self.__x_label.lift()
            self.__first_number_entry.lift()
            self.__second_number_entry.lift()
            self.__ok_calc_button.lift()
            self.__go_racing_button.lift()
            self.__give_food_button.lift()
            self.__give_drink_button.lift()
        else:
            self.__text_label.configure(text="Graag een naam van je hond invoeren.")

            # hide components:
            self.__x_label.lower()
            self.__first_number_entry.lower()
            self.__second_number_entry.lower()
            self.__ok_calc_button.lower()
            self.__go_racing_button.lower()
            self.__give_food_button.lower()
            self.__give_drink_button.lower()

    def __ok_math_button_on_click(self):
        """button click event of ok_math_button"""
        n1 = int(self.__first_number_entry.get())
        n2 = int(self.__second_number_entry.get())
        self.__text_label.configure(text=self.__dog.do_math(n1, n2))

    def __go_racing_button_on_click(self):
        """button click event of go_racing_button"""
        self.__text_label.configure(text=self.__dog.go_racing())

    def __give_food_button_on_click(self):
        """button click event of give_food_button"""
        self.__text_label.configure(text=self.__dog.get_food())

    def __give_drink_button_on_click(self):
        """button click event of give_drink_button"""
        self.__text_label.configure(text=self.__dog.get_drink())

    def __random_color(self, old_color):
        """get different color"""
        new_color = old_color
        while new_color == old_color:
            new_color = choice(self.__colors)
        return new_color
Exemplo n.º 35
0
from animal import Animal
from dragon import Dragon
from dog import Dog

print '\n'
animal = Animal('whooo')
animal.walk().walk().walk().run().run().displayHealth()
print '\n'
dog = Dog('fido')
dog.walk().walk().walk().run().run().pet().displayHealth()
print '\n'
dragon = Dragon('Draco')
dragon.walk().run().fly().displayHealth()
print '\n'
Exemplo n.º 36
0
 def __init__(self, name):
     Dog.__init__(self, name)
Exemplo n.º 37
0
from cat import Cat
from dog import Dog
import sys

print("Are you a dog lover? (y/n)", end='')
yn = sys.stdin.readline()
if yn == "y\n":
    print("Nice! High-five!")
    dog = Dog()
    print(dog.say_something())
else:
    print("Fine, I guess you'll like this...")
    cat = Cat()
    print(cat.say_something())