Repository navigation
Implement deprecated_alias, with tests - #4015
jbrockmendel wants to merge 6 commits into
Conversation
|
an you check whether that attribute deprecation is already handled by the similar numpy function. quick search: np.deprecate |
|
I took a look at that and AFAICT it is best suited to functions. I didn't see anything I could crib from pandas either. |
1 similar comment
| @classmethod | ||
| def setup_class(cls): | ||
|
|
||
| class Dummy(object): |
There was a problem hiding this comment.
there is either a tab instead of spaces or 8 instead of 4 spaces
|
|
||
| ''' | ||
|
|
||
| nvars = deprecated_alias('nvars', 'neqs', '0.11.0') |
There was a problem hiding this comment.
this could have a very short test (hopefully it can be added to an existing test)
I will need to be deleted again later
| self.ma = ma | ||
| nlags, nvarall, nvars = ar.shape | ||
| self.nlags, self.nvarall, self.nvars = nlags, nvarall, nvars | ||
| self.nlags, self.nvarall, self.neqs = nlags, nvarall, nvars |
There was a problem hiding this comment.
Do we really make this change and deprecate this?
There was a problem hiding this comment.
This is mainly an example case chosen to be small, clear, and out of the way. VARResults is a much more relevant case.
I'm not necessarily the person to ask; I think varma_process should be removed entirely and most of its functionality covered by wold.
| return getattr(self, new_name) | ||
|
|
||
| def fset(self, value): | ||
| warnings.warn(msg) |
There was a problem hiding this comment.
does this need a warnings class, e.g. DeprecationWarning.
what kind of warn does numpy deprecate issue?
There was a problem hiding this comment.
Looks like np.deprecate does warnings.warn(depdoc, DeprecationWarning, stacklevel=2). This is easy to implement, a bit harder to test. I'll take a look for examples elsewhere.
|
Ok, then this looks fine to me. a few inline comments. (I didn't think hard about what the decorator function is doing) To check: this warns only once, or does it warn repeatedly? |
Codecov Report
@@ Coverage Diff @@
## master #4015 +/- ##
==========================================
+ Coverage 79.32% 79.33% +<.01%
==========================================
Files 544 545 +1
Lines 81714 81752 +38
Branches 9255 9256 +1
==========================================
+ Hits 64820 64857 +37
- Misses 14800 14801 +1
Partials 2094 2094
Continue to review full report at Codecov.
|
| def __init__(self, ar, ma=None): | ||
| self.ar = ar | ||
| self.ma = ma | ||
| nlags, nvarall, nvars = ar.shape |
There was a problem hiding this comment.
To keep the diff small, I only changed it in the one line that sets self.nvars = nvars to set self.neqs = nvars instead.
|
OK, changed the warning to specifically issue a DeprecationWarning. testing for that is a PITA, but is now implemented. |
bashtage
left a comment
There was a problem hiding this comment.
Small suggestions. Otherwise looks ready.
|
|
||
|
|
||
| def deprecated_alias(old_name, new_name, remove_version=None): | ||
| msg = '%s is a deprecated alias for %s' % (old_name, new_name) |
There was a problem hiding this comment.
Sound you use modern syntax msg = '{0} is a ...'.format(old_name...
|
|
||
|
|
||
| def deprecated_alias(old_name, new_name, remove_version=None): | ||
| msg = '%s is a deprecated alias for %s' % (old_name, new_name) |
There was a problem hiding this comment.
Would a short docstring with an example help others find/use this?
There was a problem hiding this comment.
Good idea, will implement.
|
|
||
|
|
||
| def deprecated_alias(old_name, new_name, remove_version=None): | ||
| msg = '%s is a deprecated alias for %s' % (old_name, new_name) |
There was a problem hiding this comment.
Should modern string formatting be used '{0}'.format(var)?
There was a problem hiding this comment.
I think the pytest precedent is that its OK for me to take my time getting comfortable with that.
There was a problem hiding this comment.
I would autopep all of SM, PRs be damned.
There was a problem hiding this comment.
I would autopep all of SM, PRs be damned.
My foolish hope is that jpkt will delegate design-decision-free fixups to you and I so we can a) clear out the PR backlog and b) clean up the flaketastrophe.
|
I was wrong about the tests for DeprecationWarning working (but right about it being a PITA). Just pushed a commit that emits a FutureWarning instead, doesn't require any magic to test. |
1 similar comment
|
Merry Christmas 😀
…On Mon, Dec 25, 2017, 18:09 jbrockmendel ***@***.***> wrote:
Closed #4015 <#4015>.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4015 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFU5RZUNFccddigrOsih6FksZMOs7IX1ks5tD-TmgaJpZM4P0ueo>
.
|
Inconsistent names are An Issue. But we're not willing to go through and excise names that don't conform to current naming conventions.
This PR implements a
deprecated_aliasproperty-like attribute that warns on access but otherwise behaves normally. i.e. we can bring some consistency to the world, warn users of coming deprecations and maybe even eventually follow up on those deprecations.One example is implemented in the basically-unmaintained
tsa.varma_process.VarmaPoly.nvarscorresponds to what we would now callneqs.