HELICS icon indicating copy to clipboard operation
HELICS copied to clipboard

`helicsInputGetRawValue` and `helicsInputGetBytes` behave different in `v2.6.1` versus `v3.0.0.alpha.2`

Open kdheepak opened this issue 4 years ago • 3 comments

If I run the same code, I get different results in v2.6.1 versus v3.0.0.alpha.2.

Screen Shot 2020-11-11 at 4 20 40 PM

This is the code I'm running:

import helics as h

print("helicsGetVersion: ", h.helicsGetVersion())
print("__version__: ", h.__version__)

broker = h.helicsCreateBroker("zmq", "", "-f 1 --name=mainbroker")
fedinfo = h.helicsCreateFederateInfo()
fedinfo.core_name = "TestFederate"
fedinfo.core_type = "zmq"
fedinfo.core_init = "-f 1 --broker=mainbroker"
mFed = h.helicsCreateCombinationFederate("TestFederate", fedinfo)

_ = mFed.register_endpoint("ep1")
_ = mFed.register_global_endpoint("ep2")

pub = mFed.register_publication("publication", h.HELICS_DATA_TYPE_STRING, "custom-units")

sub = mFed.register_subscription("TestFederate/publication", "custom-units")
sub.option["CONNECTION_REQUIRED"] = 1

mFed.property[h.HELICS_PROPERTY_TIME_DELTA] = 1.0

sub.set_default(b"hello")

sub.set_default("world")

sub.set_default(0)

sub.set_default(True)

sub.set_default(1.1)

sub.set_default(2 + 1.1j)

sub.set_default([1.0, 2.0, 3.0])

sub.info = "hello world"

mFed.publications["TestFederate/publication"].option["CONNECTION_REQUIRED"] = 1

mFed.enter_executing_mode()

data = "random-data"

mFed.endpoints["TestFederate/ep1"].default_destination = "ep2"
mFed.endpoints["TestFederate/ep1"].info = "information"

mFed.endpoints["TestFederate/ep1"].send_data(data, "ep2", 1.0)

mFed.publications["TestFederate/publication"].publish("first-time")

assert mFed.request_time(2.0) == 1.0

print("""mFed.subscriptions["TestFederate/publication"].bytes: """, mFed.subscriptions["TestFederate/publication"].bytes)

assert mFed.subscriptions["TestFederate/publication"].bytes == b"first-time"

print("Exiting...")

kdheepak avatar Nov 11 '20 23:11 kdheepak

That looks like it is due to the binary type header that is included now.
It is a question of whether this behavior is desirable. I think there needs to be some way to get the raw bytes vs interpreted bytes.

phlptp avatar Nov 14 '20 15:11 phlptp

That looks like it is due to the binary type header that is included now

I don't think follow? Also, why would calling helicsInputGetBytes returning just one byte be desirable?

kdheepak avatar Nov 15 '20 02:11 kdheepak

@kdheepak and @phlptp: this is moot now in v3.1, right?

trevorhardy avatar Dec 04 '21 00:12 trevorhardy