Skip to content

Commit

Permalink
warnings.warning → warnings.warn
Browse files Browse the repository at this point in the history
Fixes #394
  • Loading branch information
flying-sheep committed Dec 12, 2018
1 parent c477f1e commit 7b1077d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion anndata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def decorator(func):
@wraps(func)
def new_func(*args, **kwargs):
warnings.simplefilter('always', DeprecationWarning) # turn off filter
warnings.warning(
warnings.warn(
'Use {0} instead of {1}, {1} will be removed in the future.'
.format(new_name, func.__name__),
category=DeprecationWarning,
Expand Down

6 comments on commit 7b1077d

@falexwolf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, @flying-sheep, the warnings module is deprecating warnings.warn over warnings.warning, that's why I changed a couple of the occurrences. I like the verbal .warn better, but it seems to go away in the future...

@flying-sheep
Copy link
Member Author

@flying-sheep flying-sheep commented on 7b1077d Dec 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all. That's another module, and the other way around. logging.warning is going away, and warnings.warning doesn't even exist (and I think it never did)

@falexwolf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was mixing up logging with warnings; that I'm also mixing up the way .warn and .warning, even better! :)

@flying-sheep
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, it’s specifically good because the fact that nobody encountered this before menas that people tend to not use the deprecated functions

@falexwolf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just got the output again: I believe it's as I thought initially logging.warn goes away and logging.warning stays:

/home/ubuntu/miniconda3/lib/python3.6/site-packages/ipykernel_launcher.py:1: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead

@flying-sheep
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh whoops! Sorry adding confusion here. So logging.warning or warnings.warn, got it.

Added bonus: One could import both if one needs both functions in the same module.

Please sign in to comment.