Skip to content

REF: make CustomMixin a cdef class #34345

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 10 commits into from
May 27, 2020

Conversation

jbrockmendel
Copy link
Member

No description provided.

@jbrockmendel jbrockmendel added the Frequency DateOffsets label May 23, 2020
@jreback jreback added this to the 1.1 milestone May 25, 2020
@jreback
Copy link
Contributor

jreback commented May 25, 2020

can you rebase

@jreback
Copy link
Contributor

jreback commented May 25, 2020

one more time :->

@jbrockmendel
Copy link
Member Author

/home/runner/work/pandas/pandas/doc/source/reference/api/pandas.tseries.offsets.BDay.calendar.rst: WARNING: document isn't included in any toctree
/home/runner/work/pandas/pandas/doc/source/reference/api/pandas.tseries.offsets.BDay.holidays.rst: WARNING: document isn't included in any toctree
/home/runner/work/pandas/pandas/doc/source/reference/api/pandas.tseries.offsets.BDay.weekmask.rst: WARNING: document isn't included in any toctree
/home/runner/work/pandas/pandas/doc/source/reference/api/pandas.tseries.offsets.BusinessDay.calendar.rst: WARNING: document isn't included in any toctree
/home/runner/work/pandas/pandas/doc/source/reference/api/pandas.tseries.offsets.BusinessDay.holidays.rst: WARNING: document isn't included in any toctree
/home/runner/work/pandas/pandas/doc/source/reference/api/pandas.tseries.offsets.BusinessDay.weekmask.rst: WARNING: document isn't included in any toctree
/home/runner/work/pandas/pandas/doc/source/reference/api/pandas.tseries.offsets.BusinessHour.calendar.rst: WARNING: document isn't included in any toctree
/home/runner/work/pandas/pandas/doc/source/reference/api/pandas.tseries.offsets.BusinessHour.holidays.rst: WARNING: document isn't included in any toctree
/home/runner/work/pandas/pandas/doc/source/reference/api/pandas.tseries.offsets.BusinessHour.weekmask.rst: WARNING: document isn't included in any toctree

cc @jorisvandenbossche suggestions for how to suppress these warnings? The situation: in order to fix [cython MRO troubles] i had to add these attributes in the declaration for these classes, but these classes never actually define/use these attributes, so they shouldnt be in the docs.

@jreback
Copy link
Contributor

jreback commented May 25, 2020

I would remove from the docs for now? once the cython classes are unified maybe can get away with re-adding?

@jbrockmendel
Copy link
Member Author

I would remove from the docs for now?

you mean remove the classes entirely?

@jorisvandenbossche
Copy link
Member

@jbrockmendel you can add those classes in the docs in a comment, so they don't show up in the overview list, but are actually built (to shut up sphinx to warn about it)
See eg at the bottom of reference/index.rst as example

@jbrockmendel
Copy link
Member Author

@jorisvandenbossche not having much luck. what ive put at the end of the document is (several variations of):

.. This is to prevent warnings in the doc build. We don't want to encourage
.. these methods.  See GH#34345

..
    BDay
    ----
    .. autosummary::
       :toctree: api/

        BDay

    Properties
    ~~~~~~~~~~
    .. autosummary::
       :toctree: api/

        BDay.base
        BDay.freqstr
        BDay.kwds
        BDay.name
        BDay.nanos
        BDay.normalize
        BDay.offset
        BDay.rule_code
        BDay.n

    Methods
    ~~~~~~~
    .. autosummary::
       :toctree: api/

        BDay.apply
        BDay.apply_index
        BDay.copy
        BDay.isAnchored
        BDay.onOffset
        BDay.is_anchored
        BDay.is_on_offset
        BDay.rollback
        BDay.rollforward
        BDay.__call__

which is giving errors:

WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay': no module named pandas.tseries.frequencies.BDay
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.__call__': no module named pandas.tseries.frequencies.BDay.__call__
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.apply': no module named pandas.tseries.frequencies.BDay.apply
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.apply_index': no module named pandas.tseries.frequencies.BDay.apply_index
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.base': no module named pandas.tseries.frequencies.BDay.base
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.copy': no module named pandas.tseries.frequencies.BDay.copy
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.freqstr': no module named pandas.tseries.frequencies.BDay.freqstr
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.isAnchored': no module named pandas.tseries.frequencies.BDay.isAnchored
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.is_anchored': no module named pandas.tseries.frequencies.BDay.is_anchored
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.is_on_offset': no module named pandas.tseries.frequencies.BDay.is_on_offset
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.kwds': no module named pandas.tseries.frequencies.BDay.kwds
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.n': no module named pandas.tseries.frequencies.BDay.n
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.name': no module named pandas.tseries.frequencies.BDay.name
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.nanos': no module named pandas.tseries.frequencies.BDay.nanos
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.normalize': no module named pandas.tseries.frequencies.BDay.normalize
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.offset': no module named pandas.tseries.frequencies.BDay.offset
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.onOffset': no module named pandas.tseries.frequencies.BDay.onOffset
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.rollback': no module named pandas.tseries.frequencies.BDay.rollback
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.rollforward': no module named pandas.tseries.frequencies.BDay.rollforward
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.BDay.rule_code': no module named pandas.tseries.frequencies.BDay.rule_code
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.Methods': no module named pandas.tseries.frequencies.Methods
WARNING: [autosummary] failed to import 'pandas.tseries.frequencies.Properties': no module named pandas.tseries.frequencies.Properties

@jorisvandenbossche
Copy link
Member

But BDay indeed doesn't exist in pd.tseries.frequencies?

@jbrockmendel
Copy link
Member Author

But BDay indeed doesn't exist in pd.tseries.frequencies?

No, it is in tseries.offsets. If I move the comment-text up to just before .. _api.frequencies: then the warning is

WARNING: [autosummary] failed to import 'pandas.tseries.offsets.Methods': no module named pandas.tseries.offsets.Methods
WARNING: [autosummary] failed to import 'pandas.tseries.offsets.Properties': no module named pandas.tseries.offsets.Properties

@jorisvandenbossche
Copy link
Member

You will need to show the change that gives this warning

@jbrockmendel
Copy link
Member Author

You will need to show the change that gives this warning

Locally, this file now ends with

    [...]
    CDay.rollback
    CDay.rollforward
    CDay.__call__

.. This is to prevent warnings in the doc build. We don't want to encourage
.. these methods.  See GH#34345

..
    BDay
    ----
    .. autosummary::
       :toctree: api/

        BDay

    Properties
    ~~~~~~~~~~
    .. autosummary::
       :toctree: api/

        BDay.base
        BDay.freqstr
        BDay.kwds
        BDay.name
        BDay.nanos
        BDay.normalize
        BDay.offset
        BDay.rule_code
        BDay.n

    Methods
    ~~~~~~~
    .. autosummary::
       :toctree: api/

        BDay.apply
        BDay.apply_index
        BDay.copy
        BDay.isAnchored
        BDay.onOffset
        BDay.is_anchored
        BDay.is_on_offset
        BDay.rollback
        BDay.rollforward
        BDay.__call__


.. _api.frequencies:

===========
Frequencies
===========
.. currentmodule:: pandas.tseries.frequencies

.. _api.offsets:

.. autosummary::
   :toctree: api/

   to_offset

@jbrockmendel
Copy link
Member Author

@jorisvandenbossche i still need to rebase+test this, so not a huge hurry, but any thoughts on the doc issue? we're at the tail end of this process

@jorisvandenbossche
Copy link
Member

Not directly, sorry. But if you can push it here, might be easier to check with the full change

@jorisvandenbossche
Copy link
Member

The docs are passing here?

@jbrockmendel
Copy link
Member Author

The docs are passing here?

Yes. In the most recent commit i added the "dummy" attributes to the docs for the non-custom classes, so if accessed they will just be None.

@jbrockmendel
Copy link
Member Author

green, booyah

@jreback jreback merged commit 556a6af into pandas-dev:master May 27, 2020
@jbrockmendel jbrockmendel deleted the ref-liboffsets-cdef-custom branch May 27, 2020 23:20
@jorisvandenbossche
Copy link
Member

In the most recent commit i added the "dummy" attributes to the docs for the non-custom classes, so if accessed they will just be None.

But why do BDay etc need to be in the docs at all?

@jbrockmendel
Copy link
Member Author

No idea

@jorisvandenbossche
Copy link
Member

It was not meant as a technical "why" question, but a documentation question, and you are the expert in offsets: is BDay a class is used by users? (or is only a base class they should never use, I don't know)

@jbrockmendel
Copy link
Member Author

BDay is an alias for BusinessDay, which i think is fairly common. It is used directly by users

@jorisvandenbossche
Copy link
Member

OK, so it's good to have it in the docs then. But maybe we could only add the class docstring page itself, without adding all methods/properties? (we have machinery for that, will do a PR just for BDay)

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.

3 participants