Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with assignment of list of enum types #33

Closed
aneels3 opened this issue Aug 12, 2020 · 2 comments
Closed

Issue with assignment of list of enum types #33

aneels3 opened this issue Aug 12, 2020 · 2 comments

Comments

@aneels3
Copy link
Contributor

aneels3 commented Aug 12, 2020

Hi @mballance
I was trying to implement an example for the randomization process like this

import vsc
from enum import Enum, auto 


class Numbers(Enum):
     Zero = 0
     One = auto()
     Two = auto()
     Three = auto()


class more_numbers(Enum):
     Eight = 8
     Nine  = auto()

@vsc.randobj
class parent_0:
    def __init__(self):
        self.count = vsc.rand_enum_t(Numbers)


@vsc.randobj
class parent_1():
    def __init__(self):
        self.list_count = vsc.randsz_list_t(vsc.enum_t(Numbers))

@vsc.randobj
class child_0(parent_0):
    def __init__(self):
        super().__init__()
        self.name = vsc.rand_enum_t(more_numbers)

@vsc.randobj
class child_1(parent_1):
    def __init__(self):
        super().__init__()
        self.child_0_ins = []
        self.length = vsc.uint8_t(10)
    def pre_randomize(self):
        #self.list_count = [None] * self.length
        pass
    
    def post_randomize(self):
        self.child_0_ins = [None] * 4
        for i in range(3):
           print=("PS: list_count", self.list_count)
           self.child_0_ins[i] = child_0()
           self.child_0_ins[i].count = self.list_count[i]
    
    @vsc.constraint
    def list_count_size(self):
        self.list_count.size == 10

child_1_ins = child_1()
child_1_ins.randomize()
print("List_Count ", child_1_ins.list_count)

After experimenting with every possibility, I am getting an attribute error as
image

I am trying to call the randomize() with the child_1 class instance to update the count variable of parent_0 class with a parent_1 list_count element.
I might be missing something here.
Can you help me with this issue?

@mballance
Copy link
Member

Hi @aneels3,
Good catch on this. I actually ran into this issue with another issue report as well. This should be resolved in the 0.1.5 release.

Best Regards,
Matthew

@aneels3
Copy link
Contributor Author

aneels3 commented Aug 17, 2020

Thanks for the support @mballance
It's working fine now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants