codecov-io: # [Codecov](https://codecov.io/gh/Becksteinlab/numkit/pull/8?src=pr&el=h1) Report
> Merging [#8](https://codecov.io/gh/Becksteinlab/numkit/pull/8?src=pr&el=desc) into [master](https://codecov.io/gh/Becksteinlab/numkit/commit/af05227af13f4bb56f867b026014048f0e3f0454?src=pr&el=desc) will **increase** coverage by `1.24%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/Becksteinlab/numkit/pull/8/graphs/tree.svg?src=pr&token=R9Mt8KahuV&height=150&width=650)](https://codecov.io/gh/Becksteinlab/numkit/pull/8?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master       #8      +/-   ##
==========================================
+ Coverage   69.11%   70.35%   +1.24%     
==========================================
  Files           5        5              
  Lines         586      587       +1     
  Branches       75       75              
==========================================
+ Hits          405      413       +8     
+ Misses        145      133      -12     
- Partials       36       41       +5
```


| [Impacted Files](https://codecov.io/gh/Becksteinlab/numkit/pull/8?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/numkit/timeseries.py](https://codecov.io/gh/Becksteinlab/numkit/pull/8/diff?src=pr&el=tree#diff-c3JjL251bWtpdC90aW1lc2VyaWVzLnB5) | `62.08% <100%> (+4.07%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Becksteinlab/numkit/pull/8?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Becksteinlab/numkit/pull/8?src=pr&el=footer). Last update [af05227...ebadff5](https://codecov.io/gh/Becksteinlab/numkit/pull/8?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

diff --git a/CHANGES b/CHANGES
index 267c22e..d6525cb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,11 @@
  CHANGELOG for numkit
 ======================
 
+2018-08-08      1.1.1
+orbeckst
+
+* fixed numkit.timeseries.smooth() under Python 3 (issue #7)
+
 2018-04-27      1.1.0
 orbeckst, kain88-de
 
diff --git a/src/numkit/timeseries.py b/src/numkit/timeseries.py
index 7d9fa4e..91ae7dc 100644
--- a/src/numkit/timeseries.py
+++ b/src/numkit/timeseries.py
@@ -2,6 +2,8 @@
 # Copyright (c) 2010 Oliver Beckstein <orbeckst@gmail.com>
 # Released under the "Modified BSD Licence" (see COPYING).
 
+from __future__ import absolute_import, division
+
 from six.moves import zip as izip
 
 import numpy
@@ -232,7 +234,7 @@ def smooth(x, window_len=11, window='flat'):
 
     s = numpy.r_[x[window_len-1:0:-1], x, x[-1:-window_len:-1]]
     y = numpy.convolve(w/w.sum(), s, mode='valid')
-    return y[(window_len-1)/2:-(window_len-1)/2]  # take off repeats on ends
+    return y[(window_len-1)//2:-(window_len-1)//2]  # take off repeats on ends
 
 def smoothing_window_length(resolution, t):
     """Compute the length of a smooting window of *resolution* time units.

timeseries.smooth() fails in Python 3
In Py 3
```
>       return y[(window_len-1)/2:-(window_len-1)/2]  # take off repeats on ends
E       TypeError: slice indices must be integers or None or have an __index__ method
```
diff --git a/src/numkit/tests/test_timeseries.py b/src/numkit/tests/test_timeseries.py
index b10d443..140d39d 100644
--- a/src/numkit/tests/test_timeseries.py
+++ b/src/numkit/tests/test_timeseries.py
@@ -47,5 +47,8 @@ class TestRegularizedFunction(object):
         # assert_almost_equal(np.max(Y), np.max(data[1]))
         # add test for Y data (but has randomness)
 
-
-
+@pytest.mark.parametrize('window', (
+    'flat', 'hanning', 'hamming', 'bartlett', 'blackman'))
+def test_smooth(data, window):
+    a = numkit.timeseries.smooth(data[1], window=window)
+    assert len(a) == len(data[1])

environment.yml
pip install -e .[dev]
parse_log_pytest
environment.yml
pytest pytest-cov pytest-pep8
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
coverage==6.2
execnet==1.9.0
importlib-metadata==4.8.3
iniconfig==1.1.1
-e git+https://github.com/Becksteinlab/numkit.git@af05227af13f4bb56f867b026014048f0e3f0454#egg=numkit
numpy @ file:///tmp/build/80754af9/numpy_and_numpy_base_1603483703303/work
packaging==21.3
pep8==1.7.1
pluggy==1.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
pytest-cache==1.0
pytest-cov==4.0.0
pytest-pep8==1.0.6
scipy @ file:///tmp/build/80754af9/scipy_1597686635649/work
six==1.17.0
tomli==1.2.3
typing_extensions==4.1.1
zipp==3.6.0

name: numkit
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - blas=1.0=openblas
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgfortran-ng=7.5.0=ha8ba4b0_17
  - libgfortran4=7.5.0=ha8ba4b0_17
  - libgomp=11.2.0=h1234567_1
  - libopenblas=0.3.18=hf726d26_0
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - numpy=1.19.2=py36h6163131_0
  - numpy-base=1.19.2=py36h75fe3a5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - scipy=1.5.2=py36habc2bb6_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - coverage==6.2
      - execnet==1.9.0
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - packaging==21.3
      - pep8==1.7.1
      - pluggy==1.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-cache==1.0
      - pytest-cov==4.0.0
      - pytest-pep8==1.0.6
      - six==1.17.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - zipp==3.6.0
prefix: /opt/conda/envs/numkit

src/numkit/tests/test_timeseries.py::test_smooth[flat] src/numkit/tests/test_timeseries.py::test_smooth[hanning] src/numkit/tests/test_timeseries.py::test_smooth[hamming] src/numkit/tests/test_timeseries.py::test_smooth[bartlett] src/numkit/tests/test_timeseries.py::test_smooth[blackman]
src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_max[5] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_max[100] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_max[1000] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_max[10000] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[5-rms_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[5-mean_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[5-std_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[5-min_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[5-max_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[5-median_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[5-percentile_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[5-error_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[5-circmean_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[5-circstd_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[5-tc_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[100-rms_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[100-mean_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[100-std_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[100-min_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[100-max_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[100-median_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[100-percentile_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[100-error_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[100-circmean_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[100-circstd_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[100-tc_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[1000-rms_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[1000-mean_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[1000-std_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[1000-min_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[1000-max_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[1000-median_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[1000-percentile_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[1000-error_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[1000-circmean_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[1000-circstd_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[1000-tc_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[10000-rms_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[10000-mean_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[10000-std_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[10000-min_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[10000-max_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[10000-median_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[10000-percentile_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[10000-error_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[10000-circmean_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[10000-circstd_histogrammed_function] src/numkit/tests/test_timeseries.py::TestRegularizedFunction::test_func[10000-tc_histogrammed_function]
src/numkit/timeseries.py CHANGES
src/numkit/timeseries.py CHANGES