Closed Staacks closed 7 years ago
I’m just trying to cover all bases - if “self.device” comes from the address string in the Labber driver dialog, it’s a unicode string and needs to be typecast under py2. If self.device comes from the ZI code, then the conversion would not be necessary. However, it doesn’t really add any overhead to add the typecasting, so it seems better to just add the typecasting everywhere
On Mar 30, 2017, at 10:51 AM, Sebastian Kuhlen notifications@github.com wrote:
Hi Simon,
you are right - sorry, should have tested all channels. I am just not exactly sure about the last one: str('/%s/clockbase' % self.device) - This is just a string constant, which should not give any trouble - at least it did not when testing. Do you expect this to become a unicode string in Python 3 as well?
Cheers, Sebastian
Simon Gustavsson notifications@github.com schrieb am Do., 30. März 2017 um 16:35 Uhr:
@simongus requested changes on this pull request.
Hi Sebastian, I saw a few extra places where typecasting might be good. Let me know if you want me to make the changes, or if you can update the code
In Zurich Instruments UHF/Zurich Instruments UHF.py https://github.com/Labber-software/Drivers/pull/31#discussion_r108942066 :
@@ -29,7 +29,7 @@ def performOpen(self, options={}): self.device = self.comCfg.address
try:
- devtype = self.ziConnection.getByte(str('/%s/features/devtype' % self.device))
- devtype = self.ziConnection.getByte('/%s/features/devtype' % self.device)
I'd keep the type casting here as well
In Zurich Instruments UHF/Zurich Instruments UHF.py https://github.com/Labber-software/Drivers/pull/31#discussion_r108942143 :
@@ -42,7 +42,7 @@ def performOpen(self, options={}): return
Check Options
- devoptions = self.ziConnection.getByte(str('/%s/features/options' % self.device))
- devoptions = self.ziConnection.getByte('/%s/features/options' % self.device)
I'd keep the type casting here as well
In Zurich Instruments UHF/Zurich Instruments UHF.py https://github.com/Labber-software/Drivers/pull/31#discussion_r108942394 :
@@ -62,11 +62,12 @@ def performSetValue(self, quant, value, sweepRate=0.0, options={}): ['Mod1On', 'Mod2On'] + \ ['Out'+str(x+1)+'SigOut' + str(y+1) + 'On' for x in range(8) for y in range(2)] + \ ['Demod'+str(x+1)+'On' for x in range(8)]:
- self.ziConnection.setInt(str(quant.get_cmd % self.device), 1 if value else 0)
- self.ziConnection.setInt(str(quant.get_cmd % self.device, 1 if value else 0))
str() should end before second argument (after self.device)
In Zurich Instruments UHF/Zurich Instruments UHF.py https://github.com/Labber-software/Drivers/pull/31#discussion_r108942678 :
@@ -169,14 +171,14 @@ def performGetValue(self, quant, options={}): else: self.wait(self.getValue("TraceStepDelayA")) self.log("Setpoint A: " + str(self.getValue("TraceStepSetpointA")))
- self.ziConnection.setDouble(str(self.instrCfg.getQuantity('TraceStepChannel').getCmdStringFromValue(self.getValue("TraceStepChannel")) % self.device), self.getValue("TraceStepSetpointA"))
- self.ziConnection.setDouble(self.instrCfg.getQuantity('TraceStepChannel').getCmdStringFromValue(self.getValue("TraceStepChannel")) % self.device, self.getValue("TraceStepSetpointA"))
keep typecasting to str for all ziConnection functions
In Zurich Instruments UHF/Zurich Instruments UHF.py https://github.com/Labber-software/Drivers/pull/31#discussion_r108942757 :
self.wait(self.getValue("TraceStepDelayB")) self.log("Setpoint B: " + str(self.getValue("TraceStepSetpointB")))
- self.ziConnection.setDouble(str(self.instrCfg.getQuantity('TraceStepChannel').getCmdStringFromValue(self.getValue("TraceStepChannel")) % self.device), self.getValue("TraceStepSetpointB"))
- self.ziConnection.setDouble(self.instrCfg.getQuantity('TraceStepChannel').getCmdStringFromValue(self.getValue("TraceStepChannel")) % self.device, self.getValue("TraceStepSetpointB"))
keep typecasting to str for all ziConnection functions
In Zurich Instruments UHF/Zurich Instruments UHF.py https://github.com/Labber-software/Drivers/pull/31#discussion_r108942784 :
while not rec.finished(): self.wait(0.05) self.traceBuffer = rec.read(True)
- self.clockbase = float(self.ziConnection.getInt(str('/%s/clockbase' % self.device)))
- self.clockbase = float(self.ziConnection.getInt('/%s/clockbase' % self.device))
keep typecasting to str for all ziConnection functions
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Labber-software/Drivers/pull/31#pullrequestreview-30009291, or mute the thread https://github.com/notifications/unsubscribe-auth/APIu4zNxo7OlRA4LZlqdgGLeGw1jmBYtks5rq72rgaJpZM4MuZZb .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Labber-software/Drivers/pull/31#issuecomment-290435699, or mute the thread https://github.com/notifications/unsubscribe-auth/AIYzH_n8Trcx7cqQDk3-yr3odMnWByZ6ks5rq8GPgaJpZM4MuZZb.
You're right - we used autodetect, so for us it came from ZI.
Simon Gustavsson notifications@github.com schrieb am Do., 30. März 2017 um 16:59 Uhr:
I’m just trying to cover all bases - if “self.device” comes from the address string in the Labber driver dialog, it’s a unicode string and needs to be typecast under py2. If self.device comes from the ZI code, then the conversion would not be necessary. However, it doesn’t really add any overhead to add the typecasting, so it seems better to just add the typecasting everywhere
On Mar 30, 2017, at 10:51 AM, Sebastian Kuhlen notifications@github.com wrote:
Hi Simon,
you are right - sorry, should have tested all channels. I am just not exactly sure about the last one: str('/%s/clockbase' % self.device) - This is just a string constant, which should not give any trouble - at least it did not when testing. Do you expect this to become a unicode string in Python 3 as well?
Cheers, Sebastian
Simon Gustavsson notifications@github.com schrieb am Do., 30. März 2017 um 16:35 Uhr:
@simongus requested changes on this pull request.
Hi Sebastian, I saw a few extra places where typecasting might be good. Let me know if you want me to make the changes, or if you can update the code
In Zurich Instruments UHF/Zurich Instruments UHF.py < https://github.com/Labber-software/Drivers/pull/31#discussion_r108942066> :
@@ -29,7 +29,7 @@ def performOpen(self, options={}): self.device = self.comCfg.address
try:
- devtype = self.ziConnection.getByte(str('/%s/features/devtype' % self.device))
- devtype = self.ziConnection.getByte('/%s/features/devtype' % self.device)
I'd keep the type casting here as well
In Zurich Instruments UHF/Zurich Instruments UHF.py < https://github.com/Labber-software/Drivers/pull/31#discussion_r108942143> :
@@ -42,7 +42,7 @@ def performOpen(self, options={}): return
Check Options
- devoptions = self.ziConnection.getByte(str('/%s/features/options' % self.device))
- devoptions = self.ziConnection.getByte('/%s/features/options' % self.device)
I'd keep the type casting here as well
In Zurich Instruments UHF/Zurich Instruments UHF.py < https://github.com/Labber-software/Drivers/pull/31#discussion_r108942394> :
@@ -62,11 +62,12 @@ def performSetValue(self, quant, value, sweepRate=0.0, options={}): ['Mod1On', 'Mod2On'] + \ ['Out'+str(x+1)+'SigOut' + str(y+1) + 'On' for x in range(8) for y in range(2)] + \ ['Demod'+str(x+1)+'On' for x in range(8)]:
- self.ziConnection.setInt(str(quant.get_cmd % self.device), 1 if value else 0)
- self.ziConnection.setInt(str(quant.get_cmd % self.device, 1 if value else 0))
str() should end before second argument (after self.device)
In Zurich Instruments UHF/Zurich Instruments UHF.py < https://github.com/Labber-software/Drivers/pull/31#discussion_r108942678> :
@@ -169,14 +171,14 @@ def performGetValue(self, quant, options={}): else: self.wait(self.getValue("TraceStepDelayA")) self.log("Setpoint A: " + str(self.getValue("TraceStepSetpointA")))
self.ziConnection.setDouble(str(self.instrCfg.getQuantity('TraceStepChannel').getCmdStringFromValue(self.getValue("TraceStepChannel")) % self.device), self.getValue("TraceStepSetpointA")) + self.ziConnection.setDouble(self.instrCfg.getQuantity('TraceStepChannel').getCmdStringFromValue(self.getValue("TraceStepChannel")) % self.device, self.getValue("TraceStepSetpointA"))
keep typecasting to str for all ziConnection functions
In Zurich Instruments UHF/Zurich Instruments UHF.py < https://github.com/Labber-software/Drivers/pull/31#discussion_r108942757> :
self.wait(self.getValue("TraceStepDelayB")) self.log("Setpoint B: " + str(self.getValue("TraceStepSetpointB")))
self.ziConnection.setDouble(str(self.instrCfg.getQuantity('TraceStepChannel').getCmdStringFromValue(self.getValue("TraceStepChannel")) % self.device), self.getValue("TraceStepSetpointB")) + self.ziConnection.setDouble(self.instrCfg.getQuantity('TraceStepChannel').getCmdStringFromValue(self.getValue("TraceStepChannel")) % self.device, self.getValue("TraceStepSetpointB"))
keep typecasting to str for all ziConnection functions
In Zurich Instruments UHF/Zurich Instruments UHF.py < https://github.com/Labber-software/Drivers/pull/31#discussion_r108942784> :
while not rec.finished(): self.wait(0.05) self.traceBuffer = rec.read(True)
- self.clockbase = float(self.ziConnection.getInt(str('/%s/clockbase' % self.device)))
- self.clockbase = float(self.ziConnection.getInt('/%s/clockbase' % self.device))
keep typecasting to str for all ziConnection functions
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/Labber-software/Drivers/pull/31#pullrequestreview-30009291 , or mute the thread < https://github.com/notifications/unsubscribe-auth/APIu4zNxo7OlRA4LZlqdgGLeGw1jmBYtks5rq72rgaJpZM4MuZZb
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/Labber-software/Drivers/pull/31#issuecomment-290435699>, or mute the thread < https://github.com/notifications/unsubscribe-auth/AIYzH_n8Trcx7cqQDk3-yr3odMnWByZ6ks5rq8GPgaJpZM4MuZZb .
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Labber-software/Drivers/pull/31#issuecomment-290437948, or mute the thread https://github.com/notifications/unsubscribe-auth/APIu47tth3a0osthuKRRudM-1wwrxeKQks5rq8MlgaJpZM4MuZZb .
Hi Simon,
you are right - sorry, should have tested all channels. I am just not exactly sure about the last one: str('/%s/clockbase' % self.device) - This is just a string constant, which should not give any trouble - at least it did not when testing. Do you expect this to become a unicode string in Python 3 as well?
Cheers, Sebastian
Simon Gustavsson notifications@github.com schrieb am Do., 30. März 2017 um 16:35 Uhr: