Giter VIP home page Giter VIP logo

Comments (2)

mballance avatar mballance commented on May 27, 2024

Hi @ShraddhaDevaiya,
I've investigated and, unfortunately, this is an unfortunate side-effect of how Python supports operator overloading. Python limits operator overloading to specific operators, and the boolean operators (and, or, not) are considered built-in and cannot be overloaded.
After investigating further, I've concluded that it's best to support dedicated methods for expressing set-membership operations. I've released a 0.0.5 version of PyVSC that provides 'inside' and 'not_inside' methods on scalar data types. Here's an example testcase using the new 'not_inside' method:

pyvsc/ve/unit/test_in.py

Lines 189 to 210 in e6a0039

def test_not_in_list_testcase(self):
@vsc.randobj
class my_s(object):
def __init__(self):
super().__init__()
self.a = vsc.rand_bit_t(8)
self.b = vsc.rand_bit_t(8)
self.temp = [1,2,3,4,5,6,7,8,9]
@vsc.constraint
def ab_c(self):
self.a.not_inside(vsc.rangelist(1, 2, (4,8)))
self.b.not_inside(vsc.rangelist(self.temp))
v = my_s()
for i in range(10):
v.randomize()
print("a=" + str(v.a) + " b=" + str(v.b))
self.assertFalse(v.a in (1,2,4,5,6,7,8))
self.assertFalse(v.b in (1,2,3,4,5,6,7,8,9))

The new 'inside' and 'not_inside' methods should work with the same combination of operands that the overloaded 'in' operator does.

Best Regards,
Matthew

from pyvsc.

ShraddhaDevaiya avatar ShraddhaDevaiya commented on May 27, 2024

It is working now, thanks for your support !

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.