Skip to content

Commit

Permalink
Avoid comparing types
Browse files Browse the repository at this point in the history
  • Loading branch information
PMeira committed Feb 12, 2024
1 parent 7851d93 commit 59fd7a4
Show file tree
Hide file tree
Showing 32 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion opendssdirect/ActiveClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def Name(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.ActiveClass_Set_Name(Value))

Expand Down
4 changes: 2 additions & 2 deletions opendssdirect/Bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def Name(self, *args):

# Setter
Value, = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)

self._check_for_error(self._Set_Name(Value))
Expand All @@ -111,7 +111,7 @@ def Idx(self, *args):

# Setter
Value, = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
self._check_for_error(self._Set_idx(Value))

__all__ = ["Iterable", "Base",]
6 changes: 3 additions & 3 deletions opendssdirect/Basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def Reset(self):
self._check_for_error(self._lib.DSS_Reset())

def SetActiveClass(self, ClassName):
if type(ClassName) is not bytes:
if not isinstance(ClassName, bytes):
ClassName = ClassName.encode(self._api_util.codec)
return self._check_for_error(self._lib.DSS_SetActiveClass(ClassName))

Expand Down Expand Up @@ -75,7 +75,7 @@ def DataPath(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.DSS_Set_DataPath(Value))

Expand Down Expand Up @@ -163,7 +163,7 @@ def ShowPanel(self):
return 0

def NewCircuit(self, name):
if type(name) is not bytes:
if not isinstance(name, bytes):
name = name.encode(self._api_util.codec)
self._check_for_error(self._lib.DSS_NewCircuit(name))
return "New Circuit" # self.ActiveCircuit
Expand Down
4 changes: 2 additions & 2 deletions opendssdirect/CapControls.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def Capacitor(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.CapControls_Set_Capacitor(Value))

Expand Down Expand Up @@ -138,7 +138,7 @@ def MonitoredObj(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.CapControls_Set_MonitoredObj(Value))

Expand Down
10 changes: 5 additions & 5 deletions opendssdirect/Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def Disable(self, Name):
Original COM help: https://opendss.epri.com/Disable.html
"""
if type(Name) is not bytes:
if not isinstance(Name, bytes):
Name = Name.encode(self._api_util.codec)
self._check_for_error(self._lib.Circuit_Disable(Name))

Expand All @@ -64,7 +64,7 @@ def Enable(self, Name):
Original COM help: https://opendss.epri.com/Enable.html
"""
if type(Name) is not bytes:
if not isinstance(Name, bytes):
Name = Name.encode(self._api_util.codec)
self._check_for_error(self._lib.Circuit_Enable(Name))

Expand Down Expand Up @@ -176,7 +176,7 @@ def SetActiveBus(self, BusName):
Original COM help: https://opendss.epri.com/SetActiveBus.html
"""
if type(BusName) is not bytes:
if not isinstance(BusName, bytes):
BusName = BusName.encode(self._api_util.codec)
return self._check_for_error(self._lib.Circuit_SetActiveBus(BusName))

Expand All @@ -199,7 +199,7 @@ def SetActiveClass(self, ClassName):
Original COM help: https://opendss.epri.com/SetActiveClass.html
"""
if type(ClassName) is not bytes:
if not isinstance(ClassName, bytes):
ClassName = ClassName.encode(self._api_util.codec)
return self._check_for_error(self._lib.Circuit_SetActiveClass(ClassName))

Expand All @@ -211,7 +211,7 @@ def SetActiveElement(self, FullName):
Original COM help: https://opendss.epri.com/SetActiveElement.html
"""
if type(FullName) is not bytes:
if not isinstance(FullName, bytes):
FullName = FullName.encode(self._api_util.codec)
return self._check_for_error(self._lib.Circuit_SetActiveElement(FullName))

Expand Down
4 changes: 2 additions & 2 deletions opendssdirect/CktElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def Variable(self, MyVarName):
If the active element is a PCElement, get the value of a variable by name.
Otherwise, an exception is raised.
"""
if type(MyVarName) is not bytes:
if not isinstance(MyVarName, bytes):
MyVarName = MyVarName.encode(self._api_util.codec)
Code = self._api_util.ffi.new("int32_t*")
result = self._check_for_error(self._lib.CktElement_Get_Variable(MyVarName, Code))
Expand Down Expand Up @@ -210,7 +210,7 @@ def DisplayName(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.CktElement_Set_DisplayName(Value))

Expand Down
6 changes: 3 additions & 3 deletions opendssdirect/Fuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def MonitoredObj(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Fuses_Set_MonitoredObj(Value))

Expand Down Expand Up @@ -141,7 +141,7 @@ def SwitchedObj(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Fuses_Set_SwitchedObj(Value))

Expand Down Expand Up @@ -171,7 +171,7 @@ def TCCCurve(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Fuses_Set_TCCcurve(Value))

Expand Down
8 changes: 4 additions & 4 deletions opendssdirect/Generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def daily(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Generators_Set_daily(Value))

Expand All @@ -222,7 +222,7 @@ def duty(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Generators_Set_duty(Value))

Expand All @@ -240,7 +240,7 @@ def Yearly(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Generators_Set_Yearly(Value))

Expand Down Expand Up @@ -316,7 +316,7 @@ def Bus1(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Generators_Set_Bus1(Value))

Expand Down
12 changes: 6 additions & 6 deletions opendssdirect/Lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ILines(Iterable):
]

def New(self, Name):
if type(Name) is not bytes:
if not isinstance(Name, bytes):
Name = Name.encode(self._api_util.codec)
return self._check_for_error(self._lib.Lines_New(Name))

Expand All @@ -57,7 +57,7 @@ def Bus1(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Lines_Set_Bus1(Value))

Expand All @@ -73,7 +73,7 @@ def Bus2(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Lines_Set_Bus2(Value))

Expand Down Expand Up @@ -142,7 +142,7 @@ def Geometry(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Lines_Set_Geometry(Value))

Expand Down Expand Up @@ -172,7 +172,7 @@ def LineCode(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Lines_Set_LineCode(Value))

Expand Down Expand Up @@ -304,7 +304,7 @@ def Spacing(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Lines_Set_Spacing(Value))

Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/LoadShape.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ILoadShape(Iterable):

def New(self, Name):
"""Create a new LoadShape, with default parameters"""
if type(Name) is not bytes:
if not isinstance(Name, bytes):
Name = Name.encode(self._api_util.codec)
return self._check_for_error(self._lib.LoadShapes_New(Name))

Expand Down
12 changes: 6 additions & 6 deletions opendssdirect/Loads.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def CVRCurve(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Loads_Set_CVRcurve(Value))

Expand Down Expand Up @@ -147,7 +147,7 @@ def Growth(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Loads_Set_Growth(Value))

Expand Down Expand Up @@ -275,7 +275,7 @@ def Spectrum(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Loads_Set_Spectrum(Value))

Expand Down Expand Up @@ -375,7 +375,7 @@ def Yearly(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Loads_Set_Yearly(Value))

Expand Down Expand Up @@ -407,7 +407,7 @@ def Daily(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Loads_Set_daily(Value))

Expand All @@ -423,7 +423,7 @@ def Duty(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Loads_Set_duty(Value))

Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Meters.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def MeteredElement(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Meters_Set_MeteredElement(Value))

Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/Monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def Element(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.Monitors_Set_Element(Value))

Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/OpenDSSDirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def __call__(self, cmds: Union[AnyStr, List[AnyStr]] = None):
'''
# self.Commands(cmds) -- inlined
if isinstance(cmds, (str, bytes)):
if type(cmds) is not bytes:
if not isinstance(cmds, bytes):
cmds = cmds.encode(self._api_util.codec)
self._check_for_error(self._lib.Text_CommandBlock(cmds))
else:
Expand Down
2 changes: 1 addition & 1 deletion opendssdirect/PDElements.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def Name(self, *args):

# Setter
(Value,) = args
if type(Value) is not bytes:
if not isinstance(Value, bytes):
Value = Value.encode(self._api_util.codec)
self._check_for_error(self._lib.PDElements_Set_Name(Value))

Expand Down
Loading

0 comments on commit 59fd7a4

Please sign in to comment.