Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #238 from ndawe/master
Browse files Browse the repository at this point in the history
[MRG] Add DeprecationWarnings for tree2rec and root2rec
  • Loading branch information
ndawe committed Apr 5, 2016
2 parents 067e9a9 + 03b6368 commit 28be355
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
10 changes: 8 additions & 2 deletions root_numpy/__init__.py
Expand Up @@ -10,7 +10,7 @@
from ._array import array
from ._matrix import matrix
from ._evaluate import evaluate
from ._warnings import RootNumpyWarning, RootNumpyUnconvertibleWarning
from ._warnings import RootNumpyUnconvertibleWarning
from ._utils import (
stretch, blockwise_inner_join,
rec2array, stack, dup_idx)
Expand Down Expand Up @@ -42,6 +42,12 @@
'stretch',
'dup_idx',
'blockwise_inner_join',
'RootNumpyWarning',
'RootNumpyUnconvertibleWarning',
]

import warnings
import re

# Make sure that DeprecationWarning within this package always gets printed
warnings.filterwarnings('always', category=DeprecationWarning,
module='^{0}\.'.format(re.escape(__name__)))
7 changes: 7 additions & 0 deletions root_numpy/_tree.py
@@ -1,3 +1,4 @@
import warnings
from glob import glob
import numpy as np

Expand Down Expand Up @@ -230,6 +231,9 @@ def root2rec(filenames,
root2array
"""
warnings.warn("root2rec is deprecated and will be removed in 4.5.0. "
"Instead use root2array(...).view(np.recarray)",
DeprecationWarning)
return root2array(filenames, treename,
branches, selection,
start, stop, step,
Expand Down Expand Up @@ -377,6 +381,9 @@ def tree2rec(tree,
tree2array
"""
warnings.warn("tree2rec is deprecated and will be removed in 4.5.0. "
"Instead use tree2array(...).view(np.recarray)",
DeprecationWarning)
return tree2array(tree,
branches=branches,
selection=selection,
Expand Down
8 changes: 1 addition & 7 deletions root_numpy/_warnings.py
Expand Up @@ -2,17 +2,11 @@


__all__ = [
'RootNumpyWarning',
'RootNumpyUnconvertibleWarning',
]


class RootNumpyWarning(RuntimeWarning):
pass


class RootNumpyUnconvertibleWarning(RootNumpyWarning):
class RootNumpyUnconvertibleWarning(RuntimeWarning):
pass

warnings.simplefilter('always', RootNumpyUnconvertibleWarning)
warnings.simplefilter('always', RootNumpyWarning)

0 comments on commit 28be355

Please sign in to comment.