1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
Description: Fix: SyntaxWarning: "is" with a literal. Did you mean "=="?
Author: Andreas Tille <tille@debian.org>
Last-Update: Thu, 11 Jan 2024 17:06:32 +0100
--- a/HMMEd/HMMEditingContext.py
+++ b/HMMEd/HMMEditingContext.py
@@ -39,10 +39,10 @@ class HMMEditingContext(object):
self.modeltype = mtype
# check whether the parameter is an EmissionDomain
if isinstance(parameter, ghmm.EmissionDomain):
- if parameter.CDataType is "int":
+ if parameter.CDataType == "int":
self.HMM = ObjectHMM(State, Transition, alphabet=parameter, etype=0)
self.modeltype |= ghmmwrapper.kDiscreteHMM
- elif parameter.CDataType is "double":
+ elif parameter.CDataType == "double":
self.HMM = ObjectHMM(State, Transition, emissionClass=ContinuousMixtureDistribution, etype=1)
self.modeltype |= ghmmwrapper.kContinuousHMM
else:
--- a/HMMEd/HMMEditor.py
+++ b/HMMEd/HMMEditor.py
@@ -433,7 +433,7 @@ class HMMGraphEditor(SAGraphEditor):
filetypes = (("XML", ".xml"),
)
)
- if file is "":
+ if file == "":
print("cancelled")
else:
self.fileName = file
@@ -468,7 +468,7 @@ class HMMGraphEditor(SAGraphEditor):
filetypes = ( ("XML", ".xml"),
)
)
- if file is not "":
+ if file != "":
self.fileName = file
self.dirty = 0
self.G.writeXML(self.fileName)
--- a/HMMEd/ObjectHMM.py
+++ b/HMMEd/ObjectHMM.py
@@ -645,9 +645,9 @@ class State(VertexObject):
self.fixed = ValidatingBool(False)
def __setattr__(self, name, value):
- if name is "emission":
+ if name == "emission":
self.Emission.set(value)
- elif name is "name":
+ elif name == "name":
try:
if self.itsHMM is not None:
vname = self.labeling
@@ -662,9 +662,9 @@ class State(VertexObject):
#object.__setattr__(self, name, value)
def __getattr__(self, name):
- if name is "emission":
+ if name == "emission":
return self.Emission.get()
- elif name is "name":
+ elif name == "name":
return self.labeling
else:
return self.__dict__[name]
@@ -1050,14 +1050,14 @@ class Transition(EdgeObject):
return "Transition from %d to %d with probability %f" % (self.tail.id, self.head.id, self.GetWeight())
def __setattr__(self, name, value):
- if name is "p":
+ if name == "p":
self.SetWeight(value)
else:
self.__dict__[name] = value
#object.__setattr__(self, name, value)
def __getattr__(self, name):
- if name is "p":
+ if name == "p":
return self.GetWeight()
else:
return self.__dict__[name]
--- a/ghmmwrapper/ghmm.py
+++ b/ghmmwrapper/ghmm.py
@@ -1355,7 +1355,7 @@ class HMMOpenFactory(HMMFactory):
result = []
for i in range(nrModels):
cmodel = getModel(i)
- if emission_domain is 'd':
+ if emission_domain == 'd':
emission_domain = Alphabet(cmodel.alphabet)
if modelType & ghmmwrapper.kLabeledStates:
labelDomain = LabelDomain(cmodel.label_alphabet)
@@ -2865,7 +2865,7 @@ class DiscreteEmissionHMM(HMM):
if self.hasFlags(kSilentStates):
raise NotImplementedError("Sorry, training of models containing silent states not yet supported.")
- if R is -1:
+ if R == -1:
R = int(math.ceil(.5*math.log(math.sqrt(len(trainingSequences)))))
#print R
if R <= 1:
|