Giter VIP home page Giter VIP logo

Comments (4)

mballance avatar mballance commented on July 3, 2024 1

Hi @felixdube, Have a look at the new unique_vec constraint in the 0.9.0 release. You can find a test showing its use here:

def test_unique_vec_smoke(self):
@vsc.randobj
class my_c(object):
def __init__(self):
self.a = vsc.rand_list_t(vsc.rand_uint16_t(1), 2)
self.b = vsc.rand_list_t(vsc.rand_uint16_t(1), 2)
self.c = vsc.rand_list_t(vsc.rand_uint16_t(1), 2)
@vsc.constraint
def index_1_constraint(self):
self.a[0] < 2
self.b[0] < 2
self.c[0] < 2
self.a[1] < 2
self.b[1] < 2
self.c[1] < 2
@vsc.constraint
def unique_list_constraint(self):
vsc.unique_vec(self.a, self.b, self.c)
it = my_c()
print("A:")
for i in range(len(it.a)):
print(" %d" % it.a[i])
print("B:")
for i in range(len(it.b)):
print(" %d" % it.b[i])
print("C:")
for i in range(len(it.c)):
print(" %d" % it.c[i])

from pyvsc.

mballance avatar mballance commented on July 3, 2024

Hi @felixdube,
The current behavior is aligned with SV behavior. Specifically, all arguments to unique are 'flattened' down to a combined list of scalar variables which must be unique.
Unfortunately, I don't think there's an easy way to synthesize your desired behavior using existing constraints. This is because you effectively need to construct an 'OR' across all the uniquification terms between the arrays.
I think it's reasonable to support 'vector' uniquification within PyVSC. Is it safe to assume that, at least for your use case, the size of all vectors is the same?

from pyvsc.

felixdube avatar felixdube commented on July 3, 2024

Hi @mballance,
Thank you for you quick reply!

Yes, in my use case, it would be okay to assume the size of the vectors is the same.

Felix

from pyvsc.

felixdube avatar felixdube commented on July 3, 2024

Awesome! Thank you for the help!

from pyvsc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.