diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 851150d5..781e23a3 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -18,11 +18,11 @@ jobs: - name: Sphinx build run: | sphinx-build doc _build - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3 - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - with: - publish_branch: gh-pages - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: _build/ - force_orphan: true \ No newline at end of file +# - name: Deploy to GitHub Pages +# uses: peaceiris/actions-gh-pages@v3 +# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} +# with: +# publish_branch: gh-pages +# github_token: ${{ secrets.GITHUB_TOKEN }} +# publish_dir: _build/ +# force_orphan: true \ No newline at end of file diff --git a/doc/index.rst b/doc/index.rst index 1fc39aab..1c406bea 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -106,7 +106,7 @@ pynapple: python neural analysis package .. grid-item-card:: Filtering :text-align: center - :link: ./user_guide/07_decoding.html + :link: ./user_guide/12_filtering.html .. image:: _static/example_thumbs/filtering.svg :class: dark-light diff --git a/pynapple/core/time_series.py b/pynapple/core/time_series.py index dc1e84ff..734a0c4b 100644 --- a/pynapple/core/time_series.py +++ b/pynapple/core/time_series.py @@ -1206,8 +1206,8 @@ def __getitem__(self, key, *args, **kwargs): else: index = self.index.__getitem__(key) - if isinstance(index, Number): - index = np.array([index]) + # if isinstance(index, Number): + # index = np.array([index]) if all(is_array_like(a) for a in [index, output]): if isinstance(key, tuple): diff --git a/tests/test_time_series.py b/tests/test_time_series.py index 354104ed..7a17aedf 100755 --- a/tests/test_time_series.py +++ b/tests/test_time_series.py @@ -1029,28 +1029,34 @@ def test_horizontal_slicing(self, tsdframe, index, nap_type): ], ) def test_vertical_slicing(self, tsdframe, index): - assert isinstance(tsdframe[index], nap.TsdFrame) - if len(tsdframe[index] == 1): - # use ravel to ignore shape mismatch - np.testing.assert_array_almost_equal( - tsdframe.values[index].ravel(), tsdframe[index].values.ravel() - ) + if isinstance(index, int): + assert isinstance(tsdframe[index], np.ndarray) else: + assert isinstance(tsdframe[index], nap.TsdFrame) + + output = tsdframe[index] + if isinstance(output, nap.TsdFrame): + if len(output == 1): + # use ravel to ignore shape mismatch + np.testing.assert_array_almost_equal( + tsdframe.values[index].ravel(), output.values.ravel() + ) + else: + np.testing.assert_array_almost_equal( + tsdframe.values[index], output.values + ) + assert isinstance(output.time_support, nap.IntervalSet) np.testing.assert_array_almost_equal( - tsdframe.values[index], tsdframe[index].values + output.time_support, tsdframe.time_support ) - assert isinstance(tsdframe[index].time_support, nap.IntervalSet) - np.testing.assert_array_almost_equal( - tsdframe[index].time_support, tsdframe.time_support - ) - if len(tsdframe.metadata_columns): - assert np.all(tsdframe[index].metadata_columns == tsdframe.metadata_columns) - assert np.all(tsdframe[index].metadata_index == tsdframe.metadata_index) + if len(tsdframe.metadata_columns): + assert np.all(output.metadata_columns == tsdframe.metadata_columns) + assert np.all(output.metadata_index == tsdframe.metadata_index) @pytest.mark.parametrize( "row", [ - 0, + # 0, [0, 2], slice(20, 30), np.hstack([np.zeros(10, bool), True, True, True, np.zeros(87, bool)]), @@ -1108,28 +1114,35 @@ def test_vert_and_horz_slicing(self, tsdframe, row, col, expected): else: assert isinstance(tsdframe[row, col], expected) - if len(tsdframe[row, col] == 1): - # use ravel to ignore shape mismatch + output = tsdframe[row, col] + + if isinstance(output, nap.TsdFrame): + if len(tsdframe[row, col] == 1): + # use ravel to ignore shape mismatch + np.testing.assert_array_almost_equal( + tsdframe.values[row, col].ravel(), + tsdframe[row, col].values.ravel(), + ) + else: + np.testing.assert_array_almost_equal( + tsdframe.values[row, col], tsdframe[row, col].values + ) + assert isinstance(tsdframe[row, col].time_support, nap.IntervalSet) np.testing.assert_array_almost_equal( - tsdframe.values[row, col].ravel(), tsdframe[row, col].values.ravel() + tsdframe[row, col].time_support, tsdframe.time_support ) + if isinstance(tsdframe[row, col], nap.TsdFrame) and len( + tsdframe[row, col].metadata_columns + ): + assert np.all( + tsdframe[row, col].metadata_columns == tsdframe.metadata_columns + ) + assert np.all( + tsdframe[row, col].metadata_index + == tsdframe.metadata_index[col] + ) else: - np.testing.assert_array_almost_equal( - tsdframe.values[row, col], tsdframe[row, col].values - ) - assert isinstance(tsdframe[row, col].time_support, nap.IntervalSet) - np.testing.assert_array_almost_equal( - tsdframe[row, col].time_support, tsdframe.time_support - ) - if isinstance(tsdframe[row, col], nap.TsdFrame) and len( - tsdframe[row, col].metadata_columns - ): - assert np.all( - tsdframe[row, col].metadata_columns == tsdframe.metadata_columns - ) - assert np.all( - tsdframe[row, col].metadata_index == tsdframe.metadata_index[col] - ) + np.testing.assert_array_almost_equal(output, tsdframe.values[row, col]) @pytest.mark.parametrize("index", [0, [0, 2]]) def test_str_indexing(self, tsdframe, index):