Skip to content

ENH: mul(Tick, float); simplify to_offset #34486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 1, 2020

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented May 30, 2020

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

This will let us remove Resolution.get_stride_from_decimal

@@ -743,6 +747,25 @@ cdef class Tick(SingleConstructorOffset):
"Tick offset with `normalize=True` are not allowed."
)

# FIXME: Without making this cpdef, we get AttributeError when calling
# from __mul__
cpdef Tick _next_higher_resolution(Tick self):
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't this be better as a module level routine?

Copy link
Member Author

Choose a reason for hiding this comment

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

i dont think so. it uses self.n, so really makes sense as a method

@@ -3563,6 +3601,9 @@ cpdef to_offset(freq):
>>> to_offset(Hour())
<Hour>
"""
# TODO: avoid runtime imports
Copy link
Contributor

Choose a reason for hiding this comment

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

really really prefer absolute imports

Copy link
Member Author

Choose a reason for hiding this comment

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

sure. im more concerned about getting rid of the runtime imports

@@ -3598,15 +3641,19 @@ cpdef to_offset(freq):
if not stride:
stride = 1

Copy link
Contributor

Choose a reason for hiding this comment

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

can you give some comments on what is being done here

@jreback jreback added the Frequency DateOffsets label May 31, 2020
assert isinstance(result, Micro)

# Case where we bump up to the next type
result = off * 1.25
Copy link
Contributor

Choose a reason for hiding this comment

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

was this buggy before? need a whatsnew note if so

Copy link
Member Author

Choose a reason for hiding this comment

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

ATM it raises TypeError for any float, will add whatsnew

@jreback
Copy link
Contributor

jreback commented May 31, 2020

kk if u can rebase

@jbrockmendel
Copy link
Member Author

rebased+green

@jreback jreback added this to the 1.1 milestone Jun 1, 2020
@jreback jreback merged commit 6eb34f1 into pandas-dev:master Jun 1, 2020
@jbrockmendel jbrockmendel deleted the ref-to_offset-2 branch June 1, 2020 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frequency DateOffsets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants