Skip to content

NameError: name 'long' is not defined using python3 #778

Open
@jdamp

Description

@jdamp

I want to construct a new histogram using a sliced view of another. However, when I try to construct the new histogram from the sliced one, for example with the code from the slicing documentation

>> from rootpy.plotting import Hist3D
>> a = Hist3D(10, 0, 1, 10, 0, 1, 10, 0, 1)
>> b = Hist3D(a[3:5,::2,:])

I get the following error when using python3:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jodamp/.local/lib/python3.6/site-packages/rootpy/plotting/hist.py", line 2362, in __new__
    obj = Hist3D(other.xedges, other.yedges, other.zedges, **kwargs)
  File "/home/jodamp/.local/lib/python3.6/site-packages/rootpy/decorators.py", line 225, in __get__
    result = self.method(inst)
  File "/home/jodamp/.local/lib/python3.6/site-packages/rootpy/plotting/hist.py", line 178, in xedges
    bin_to_edge_slice(self.x, self.hist.nbins(axis=0, overflow=True))]
  File "/home/jodamp/.local/lib/python3.6/site-packages/rootpy/plotting/hist.py", line 55, in bin_to_edge_slice
    s = canonify_slice(s, n)
  File "/home/jodamp/.local/lib/python3.6/site-packages/rootpy/plotting/hist.py", line 43, in canonify_slice
    if isinstance(s, (int, long)):
NameError: name 'long' is not defined

This could be fixed for example using six as done here to modify the method canonify_slice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions