LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Malleable VI: How to assert a set

Highlighted

I am trying to make malleable via that should only work on a set. I am stumped what in Assert Type Palette to use to verify that what being feed is set. The datatype of the set is not important.

__________________________________
Bill Eisenhower
Certified LabVIEW & TestStand Developer
0 Kudos
Message 1 of 10
(310 Views)

Well, you could try to insert the first element into its set (would break for all non-sets).

 

Maybe there are better solutions, but this seems to work.

 

altenbach_0-1581638314683.png

 


LabVIEW Champion. It all comes together in GCentral GCentral
Message 2 of 10
(272 Views)
Highlighted

Don't have LabVIEW here to check, but I thought the "Set Intersection" function was a malleable VI; maybe there is a clue in there.

 

mcduff

0 Kudos
Message 3 of 10
(260 Views)
Highlighted

The trick is to assert, while actually not adding any workload.

 

I don't have sets yet... But this works for arrays:

Assert Set.PNG

Put any set function that has a set in and set out in the disabled case of the disabled structure. This does not do anything! But it defines the output type. Don't wire the enabled case. If the input is no set, the output terminal will be undefined, and the TSS will fail.

 

If it succeeds, his code won't do anything.

Message 4 of 10
(227 Views)
Highlighted

Mcduff: I looked at the set VIMs, but they do not have assertions. They just seems to be relying on the set functions used to break when something other than a Set is input.

wiebe@CARYA: I tried your idea with set function; however, it did not work as I hopped. When an Array given instead of a Set, the VI/wire were not broken unless I enable the case.

Basically for now, it looks like I have to do what altenbach suggested. Hopefully there will be an assert set added in a future version of LabVIEW. (Idea filed)

__________________________________
Bill Eisenhower
Certified LabVIEW & TestStand Developer
0 Kudos
Message 5 of 10
(207 Views)
Highlighted

My real issue is with arrays being input, so I could do an Assert Mismatch with an array of every type. However that feels a very long way to do this.

__________________________________
Bill Eisenhower
Certified LabVIEW & TestStand Developer
0 Kudos
Message 6 of 10
(205 Views)
Highlighted

As I posted in the idea exchange, there shouldn't be a need to do an assert for set or map. Just do the operation. There are plenty of VIMs for sets and maps in their respective palettes. No assert nodes needed. Here is "Set Union.vim" for example:

AristosQueue_0-1581711532957.png

Any non-set type will break this VI. And any set type will succeed. Exactly the desired behavior.

 

The assert nodes are really only needed when you want specific behavior for things that would otherwise coerce into a general case, like having different math ops for integers vs floats vs complex.

0 Kudos
Message 7 of 10
(184 Views)
Highlighted

PS: If you're doing something that only involves iterating over elements, why are you wanting to rule out arrays? Or any other type that we add iteration support for in the future? VIMs are meant to allow themselves to work on any type that works on the VIM's syntax. Ruling out types arbitrarily just limits the code reuse. Thus far, we have seen no VIMs that provide a good argument for that kind of limitation. If you have one, I'd be interested.

Message 8 of 10
(183 Views)
Highlighted

AristosQueue: I see your point. Only reason I might want to break for arrays would be as to point users to the more efficient methods already built in for arrays.

__________________________________
Bill Eisenhower
Certified LabVIEW & TestStand Developer
0 Kudos
Message 9 of 10
(105 Views)
Highlighted

If you're worried about users not using the more efficient built-in methods, the easy trick is to put a TS structure in that handles only arrays and calls the built-in functions. That's similar to what I've done in the "Sort 1D Array.vim" that is in "vi.lib\Array\" directory of LV 2019 -- if you don't use any of the advanced sort terminals on the VIM, the VIM degenerates down to just the Sort 1D Array primitive. You can do similar for your operations.

Message 10 of 10
(81 Views)