From f1fb939d10b3d9002d8dc217602dad70597cd6bc Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 14 Jun 2019 16:03:10 +0100 Subject: [PATCH 1/7] DOC: Failing documentation build on warnings --- azure-pipelines.yml | 5 ++++- doc/source/getting_started/10min.rst | 1 + doc/sphinxext/contributors.py | 7 +++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b40d46bdebe02..dc9484282f1ae 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -134,7 +134,10 @@ jobs: - script: | export PATH=$HOME/miniconda3/bin:$PATH source activate pandas-dev - doc/make.py + # Next we should simply have `doc/make.py --warnings-are-errors`, everything else is required because the ipython directive doesn't fail the build on errors (https://github.com/ipython/ipython/issues/11547) + doc/make.py --warnings-are-errors | tee -a sphinx.log ; SPHINX_RET=${PIPESTATUS[0]} + grep -B1 "^<<<-------------------------------------------------------------------------$" sphinx.log ; IPY_RET=$(( $? != 1 )) + exit $(( $SPHINX_RET + $IPY_RET )) displayName: 'Build documentation' - script: | diff --git a/doc/source/getting_started/10min.rst b/doc/source/getting_started/10min.rst index fdf1f05b8e61f..8bb188419cb59 100644 --- a/doc/source/getting_started/10min.rst +++ b/doc/source/getting_started/10min.rst @@ -712,6 +712,7 @@ See the :ref:`Plotting ` docs. plt.close('all') .. ipython:: python + :okwarning: ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000)) diff --git a/doc/sphinxext/contributors.py b/doc/sphinxext/contributors.py index 179ba19a0908a..7794a24dad89b 100644 --- a/doc/sphinxext/contributors.py +++ b/doc/sphinxext/contributors.py @@ -21,12 +21,15 @@ class ContributorsDirective(Directive): def run(self): range_ = self.arguments[0] + if range_.endswith('x..HEAD'): + return [nodes.paragraph(), nodes.bullet_list()] try: components = build_components(range_) - except git.GitCommandError: + except git.GitCommandError as exc: return [ self.state.document.reporter.warning( - "Cannot find contributors for range '{}'".format(range_), + "Cannot find contributors for range '{}': {}".format( + range_, exc), line=self.lineno) ] else: From 9058d870ef0116dcef4a75235b44627ea7003707 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 14 Jun 2019 17:18:40 +0100 Subject: [PATCH 2/7] Adding docstrings to attributes generating warnings, and installing xsel for docs --- azure-pipelines.yml | 5 +++-- pandas/core/dtypes/base.py | 16 +++++++++++----- pandas/core/indexes/base.py | 13 ++++++++++++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dc9484282f1ae..dbc0f83e61bf9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -5,6 +5,7 @@ jobs: parameters: name: macOS vmImage: xcode9-macos10.13 + - template: ci/azure/posix.yml parameters: name: Linux @@ -127,7 +128,7 @@ jobs: - script: | export PATH=$HOME/miniconda3/bin:$PATH - sudo apt-get install -y libc6-dev-i386 + sudo apt-get install -y libc6-dev-i386 xsel ci/setup_env.sh displayName: 'Setup environment and build pandas' @@ -135,7 +136,7 @@ jobs: export PATH=$HOME/miniconda3/bin:$PATH source activate pandas-dev # Next we should simply have `doc/make.py --warnings-are-errors`, everything else is required because the ipython directive doesn't fail the build on errors (https://github.com/ipython/ipython/issues/11547) - doc/make.py --warnings-are-errors | tee -a sphinx.log ; SPHINX_RET=${PIPESTATUS[0]} + doc/make.py --warnings-are-errors | tee sphinx.log ; SPHINX_RET=${PIPESTATUS[0]} grep -B1 "^<<<-------------------------------------------------------------------------$" sphinx.log ; IPY_RET=$(( $? != 1 )) exit $(( $SPHINX_RET + $IPY_RET )) displayName: 'Build documentation' diff --git a/pandas/core/dtypes/base.py b/pandas/core/dtypes/base.py index d1d48f9810419..e7191136a7d53 100644 --- a/pandas/core/dtypes/base.py +++ b/pandas/core/dtypes/base.py @@ -68,11 +68,6 @@ class property**. ``pandas.errors.AbstractMethodError`` and no ``register`` method is provided for registering virtual subclasses. """ - # na_value is the default NA value to use for this type. This is used in - # e.g. ExtensionArray.take. This should be the user-facing "boxed" version - # of the NA value, not the physical NA value for storage. - # e.g. for JSONArray, this is an empty dictionary. - na_value = np.nan _metadata = () # type: Tuple[str, ...] def __str__(self): @@ -114,6 +109,17 @@ def __hash__(self): def __ne__(self, other): return not self.__eq__(other) + @property + def na_value(self): + """ + Default NA value to use for this type. + + This is used in e.g. ExtensionArray.take. This should be the + user-facing "boxed" version of the NA value, not the physical NA value + for storage. e.g. for JSONArray, this is an empty dictionary. + """ + return np.nan + @property def type(self) -> Type: """ diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 9f0f89a0e34f5..4601d63f2d27e 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -229,7 +229,6 @@ def _outer_indexer(self, left, right): _data = None _id = None name = None - asi8 = None _comparables = ['name'] _attributes = ['name'] _is_numeric_dtype = False @@ -501,6 +500,18 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None, See each method's docstring. """ + @property + def asi8(self): + """ + Integer representation of the values. + + Returns + ------- + ndarray + An ndarray with int64 dtype. + """ + return None + @classmethod def _simple_new(cls, values, name=None, dtype=None, **kwargs): """ From ef11408d732e53203c87bc5af1794302861e7946 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 14 Jun 2019 18:19:43 +0100 Subject: [PATCH 3/7] Replacing xsel by xclip --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dbc0f83e61bf9..27dfdece4c3b5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -128,7 +128,7 @@ jobs: - script: | export PATH=$HOME/miniconda3/bin:$PATH - sudo apt-get install -y libc6-dev-i386 xsel + sudo apt-get install -y libc6-dev-i386 xclip ci/setup_env.sh displayName: 'Setup environment and build pandas' From bf39883ae48957d7e60bcc5e77bb8024195c7a88 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 14 Jun 2019 19:02:47 +0100 Subject: [PATCH 4/7] Setting up clipboard in docs build --- azure-pipelines.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 27dfdece4c3b5..864d35197e91d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -128,10 +128,18 @@ jobs: - script: | export PATH=$HOME/miniconda3/bin:$PATH - sudo apt-get install -y libc6-dev-i386 xclip + sudo apt-get install -y libc6-dev-i386 ci/setup_env.sh displayName: 'Setup environment and build pandas' + - script: | + sudo apt-get install -y xsel + export DISPLAY=":99.0" + echo "sh -e /etc/init.d/xvfb start" + sh -e /etc/init.d/xvfb start + sleep 3 + displayName: 'Setup clipboard' + - script: | export PATH=$HOME/miniconda3/bin:$PATH source activate pandas-dev From ed38affadd6774919348a11aa7a8a4282a535b0f Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 14 Jun 2019 20:02:21 +0100 Subject: [PATCH 5/7] Installing xvfb --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 864d35197e91d..95c8a7f2cb390 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -133,9 +133,9 @@ jobs: displayName: 'Setup environment and build pandas' - script: | - sudo apt-get install -y xsel + set -x + sudo apt-get install -y xsel xvfb export DISPLAY=":99.0" - echo "sh -e /etc/init.d/xvfb start" sh -e /etc/init.d/xvfb start sleep 3 displayName: 'Setup clipboard' From 5849164483d1d94afa63b7fec68afd6815aa977b Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Sun, 16 Jun 2019 22:10:25 +0100 Subject: [PATCH 6/7] Removing clipboard stuff (did not work) and fixing clipboard examples in the docs --- azure-pipelines.yml | 8 -------- doc/source/user_guide/io.rst | 29 ++++++++++++++++++++++------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 95c8a7f2cb390..9238c27002337 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -132,14 +132,6 @@ jobs: ci/setup_env.sh displayName: 'Setup environment and build pandas' - - script: | - set -x - sudo apt-get install -y xsel xvfb - export DISPLAY=":99.0" - sh -e /etc/init.d/xvfb start - sleep 3 - displayName: 'Setup clipboard' - - script: | export PATH=$HOME/miniconda3/bin:$PATH source activate pandas-dev diff --git a/doc/source/user_guide/io.rst b/doc/source/user_guide/io.rst index 725af8ef8769b..1b63f31d6d1a9 100644 --- a/doc/source/user_guide/io.rst +++ b/doc/source/user_guide/io.rst @@ -3249,24 +3249,39 @@ And then import the data directly to a ``DataFrame`` by calling: .. code-block:: python - clipdf = pd.read_clipboard() - -.. ipython:: python - - clipdf - + >>> clipdf = pd.read_clipboard() + >>> clipdf + A B C + x 1 4 p + y 2 5 q + z 3 6 r The ``to_clipboard`` method can be used to write the contents of a ``DataFrame`` to the clipboard. Following which you can paste the clipboard contents into other applications (CTRL-V on many operating systems). Here we illustrate writing a ``DataFrame`` into clipboard and reading it back. -.. ipython:: python +.. code-block:: python df = pd.DataFrame(np.random.randn(5, 3)) df df.to_clipboard() pd.read_clipboard() + >>> df = pd.DataFrame({'A': [1, 2, 3], + ... 'B': [4, 5, 6], + ... 'C': ['p', 'q', 'r']}, + ... index=['x', 'y', 'z']) + >>> df + A B C + x 1 4 p + y 2 5 q + z 3 6 r + >>> df.to_clipboard() + >>> pd.read_clipboard() + A B C + x 1 4 p + y 2 5 q + z 3 6 r We can see that we got the same content back, which we had earlier written to the clipboard. From 708dbb75818c6e31d9618841881c9dc7bdd98eff Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Mon, 17 Jun 2019 07:50:17 +0200 Subject: [PATCH 7/7] fixup clipboard example --- doc/source/user_guide/io.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/source/user_guide/io.rst b/doc/source/user_guide/io.rst index 1b63f31d6d1a9..30a42de2ab287 100644 --- a/doc/source/user_guide/io.rst +++ b/doc/source/user_guide/io.rst @@ -3263,10 +3263,6 @@ applications (CTRL-V on many operating systems). Here we illustrate writing a .. code-block:: python - df = pd.DataFrame(np.random.randn(5, 3)) - df - df.to_clipboard() - pd.read_clipboard() >>> df = pd.DataFrame({'A': [1, 2, 3], ... 'B': [4, 5, 6], ... 'C': ['p', 'q', 'r']},