Skip to content

Instantly share code, notes, and snippets.

@sparticlesteve
Created May 4, 2015 18:39
Show Gist options
  • Save sparticlesteve/9719d699e8c716246a3e to your computer and use it in GitHub Desktop.
Save sparticlesteve/9719d699e8c716246a3e to your computer and use it in GitHub Desktop.
Demonstrate error from operator== usage for SystematicVariation
#!/usr/bin/env python
from ROOT import gROOT
gROOT.SetBatch()
from ROOT import gSystem
gSystem.Load('libPATInterfaces.so')
from ROOT import CP
from ROOT.CP import SystematicVariation
# Get the equality operator
eq = getattr(CP, 'operator==')
# Custom comparison works
#def comp_systs(self, other):
# return eq(self, other)
#SystematicVariation.__eq__ = comp_systs
# Setting operator directly gives error
SystematicVariation.__eq__ = eq
# Two "equal" objects
s1 = SystematicVariation('sys', 1)
s2 = SystematicVariation('sys', 1)
print 's1 == s2:', s1 == s2
@sparticlesteve
Copy link
Author

Error message:

Traceback (most recent call last):
  File "./sys_equality_error.py", line 25, in <module>
    print 's1 == s2:', s1 == s2
TypeError: none of the 2 overloaded methods succeeded. Full details:
  static bool CP::operator==(const CP::SystematicVariation& a, const CP::SystematicVariation& b) =>
    takes at least 2 arguments (1 given)
  static bool CP::operator==(const CP::SystematicSet& a, const CP::SystematicSet& b) =>
    takes at least 2 arguments (1 given)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment