-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
COMPAT: Scalar types immutable #17116
Comments
Yes, it sure seems like
The standard way is to hide attributes like class Period(object):
...
@property
def freq(self):
return self._freq |
OK, I can take care of this. As long as we're looking at futzing with Right now two |
@jbrockmendel Comparisons between periods with different frequencies is also worth discussing, but please open a separate issue for that. |
In profiling some downstream code I found that |
Note that we don't explicity test, nor write down anywhere, the implicit guarantee for the pandas scalars So most important are tests here. This is almost trivial to fix. See how Would appreciate tests on all of the scalar types. |
Current definition:
So just change "cdef public" to "cdef readonly"?
I'm happy to help, but am stretched pretty thin. For now I need to triage. |
Yes, that is correct.
No worries! This is not urgent, so feel free to take your time on this. |
What about for the non-cython |
Changing
Please advise. |
@jbrockmendel : I think what you should do is try to see which attribute you can make |
There are only two |
Can you initialize them in |
Correction:
Changing
Then the constructor "works", but...
Also |
@jbrockmendel : I know you said you were stretched thin logistically, so this is great that you've been able to dive into this refactoring with some detail. No worries if you're stuck. At least people will know where to pick things up for the time being. |
Possibly closed by #21341 |
@jbrockmendel : Would you be able to confirm? Can we add tests to check? |
My impression (discussion somewhere on gitter) is that
pd.Period
is supposed to be immutable. That would certainly make sense for objects going into aPeriodIndex
.per.freq
is aDateOffset
object*, which is defined intseries.offsets
. There is a comment intseries.offsets.BusinessHourMixin.apply
saying "# calculate here because offset is not immutable".So a couple of questions:
pd.Period
should be immutable? If so, is there a preferred way of imposing that? Note that the class is defined in a .pyx file and some methods explicitly call__new__
.__init__
and__setstate__
, the only place intseries.offsets
where I see anyself.foo
attributes being set isself.daytime = False
inBusinessHourMixin._get_business_hours_by_sec
. grepping for "daytime", this attribute does not appear to be referenced anywhere else.* BTW, I think
DateOffset
is one of a small number of commonly-used classes for which there is not aABCDateOffset
equivalent. Is that by design? If not, I'll be happy to make one.The text was updated successfully, but these errors were encountered: