Skip to content

Commit

Permalink
EHN Refactoring to use pandas and simplify the API (#17)
Browse files Browse the repository at this point in the history
* EHN huge refactoring

* Add cyhon

* Update metrics

* MAIN add pandas

* EHN windows

* coverage

* compatibility windows

* several update

* update

* add test extraction

* DOC update sections

* DOC update examples in docstring
  • Loading branch information
glemaitre committed Jan 7, 2018
1 parent 136a9be commit 4d56123
Show file tree
Hide file tree
Showing 75 changed files with 51,036 additions and 6,357 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ source = skcycling
include = */skcycling/*
omit =
omit =
*/skcycling/__check_build/*
*/skcycling/extraction/setup.py
*/skcycling/setup.py
*/setup.py

[report]
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,6 @@ install_manifest.txt

.ipynb_checkpoints

coverage/
coverage/

cythonize.dat
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ install:
# Add Library/bin directory to fix issue
# https://github.com/conda/conda/issues/1753
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PYTHON%\\Library\\bin;%PATH%"
- conda install pip numpy scipy six joblib pytest pytest-cov -y -q
- conda install pip numpy scipy pandas cython scikit-learn six joblib pytest pytest-cov -y -q
- pip install fitparse
- pip install .

Expand Down
9 changes: 4 additions & 5 deletions build_tools/travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ if [[ "$DISTRIB" == "conda" ]]; then
# provided versions
conda create -n testenv --yes python=$PYTHON_VERSION pip
source activate testenv
conda install --yes numpy scipy six joblib
conda install --yes numpy scipy pandas six joblib scikit-learn cython
pip install fitparse

conda install --yes nose pytest pytest-cov
# Install nose-timer via pip
pip install nose-timer codecov
pip install codecov

elif [[ "$DISTRIB" == "ubuntu" ]]; then
# At the time of writing numpy 1.9.1 is included in the travis
Expand All @@ -62,8 +61,8 @@ elif [[ "$DISTRIB" == "ubuntu" ]]; then
# Create a new virtualenv using system site packages for python, numpy
virtualenv --system-site-packages testvenv
source testvenv/bin/activate
pip install --upgrade joblib six fitparse nose nose-timer pytest pytest-cov \
codecov
pip install --upgrade pandas joblib scikit-learn six fitparse \
pytest pytest-cov codecov cython

fi

Expand Down
16 changes: 16 additions & 0 deletions doc/_templates/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
:mod:`{{module}}`.{{objname}}
{{ underline }}==============

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}

{% block methods %}
.. automethod:: __init__
{% endblock %}

.. include:: {{module}}.{{objname}}.examples

.. raw:: html

<div style='clear:both'></div>
12 changes: 12 additions & 0 deletions doc/_templates/function.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
:mod:`{{module}}`.{{objname}}
{{ underline }}====================

.. currentmodule:: {{ module }}

.. autofunction:: {{ objname }}

.. include:: {{module}}.{{objname}}.examples

.. raw:: html

<div style='clear:both'></div>
16 changes: 16 additions & 0 deletions doc/_templates/numpydoc_docstring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{index}}
{{summary}}
{{extended_summary}}
{{parameters}}
{{returns}}
{{yields}}
{{other_parameters}}
{{attributes}}
{{raises}}
{{warns}}
{{warnings}}
{{see_also}}
{{notes}}
{{references}}
{{examples}}
{{methods}}
100 changes: 46 additions & 54 deletions doc/api.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##################################
`scikit-cycling` API documentation
##################################
####################
`scikit-cycling` API
####################

This is the full API documentation of `scikit-cycling`

Expand All @@ -9,121 +9,113 @@ This is the full API documentation of `scikit-cycling`
Data-management
===============

.. automodule:: skcycling.data_management
:no-members:
:no-inherited-members:

.. currentmodule:: skcycling

.. autosummary::
:toctree: generated/

data_management.Rider
Rider

.. _datasets_ref:
.. _extraction_ref:

Datasets
========
Extraction
==========

.. automodule:: skcycling.datasets
.. automodule:: skcycling.extraction
:no-members:
:no-inherited-members:

.. currentmodule:: skcycling

.. autosummary::
:toctree: generated/
:template: function.rst

datasets.load_toy
extraction.activity_power_profile

.. _power_profile_ref:
.. _metrics_ref:

Power profile
=============
Extraction
==========

.. automodule:: skcycling.power_profile
.. automodule:: skcycling.metrics
:no-members:
:no-inherited-members:

.. currentmodule:: skcycling

Single cycling activity
-----------------------

.. autosummary::
:toctree: generated/
:template: function.rst

power_profile.RidePowerProfile
power_profile.RecordPowerProfile

.. _restoration_ref:

Restoration
===========

.. automodule:: skcycling.restoration
:no-members:
:no-inherited-members:
metrics.normalized_power_score
metrics.intensity_factor_ftp_score
metrics.intensity_factor_mpa_score
metrics.training_stress_ftp_score
metrics.training_stress_mpa_score
metrics.training_stress_mpa_grappe_score
metrics.training_stress_ftp_grappe_score

.. currentmodule:: skcycling
Power-profile
-------------

.. autosummary::
:toctree: generated/
:template: function.rst

restoration.moving_average
restoration.outliers_rejection
metrics.aerobic_meta_model

.. _utilities_ref:
.. _utils_ref:

Utilities
=========

.. _io_utilities_ref:

IO utilities
------------

.. automodule:: skcycling.utils.io_fit
.. automodule:: skcycling.utils
:no-members:
:no-inherited-members:

.. currentmodule:: skcycling

.. autosummary::
:toctree: generated/
:template: function.rst

utils.load_power_from_fit
utils.validate_filenames

.. _fit_utilities_ref:
.. _io_ref:

Fit utilities
-------------
IO interaction
==============

.. automodule:: skcycling.utils.fit
.. automodule:: skcycling.io
:no-members:
:no-inherited-members:

.. currentmodule:: skcycling

.. autosummary::
:toctree: generated/
:template: function.rst

utils.res_std_dev
utils.r_squared
utils.log_linear_fitting
utils.linear_model
utils.log_linear_model
io.bikeread

.. _checker_utilities_ref:
.. _datasets_ref:

Checker utilities
-----------------
Datasets
========

.. automodule:: skcycling.utils.checker
.. automodule:: skcycling.datasets
:no-members:
:no-inherited-members:

.. currentmodule:: skcycling

.. autosummary::
:toctree: generated/
:template: function.rst

utils.check_tuple_date
utils.check_filename_fit
datasets.load_fit
datasets.load_rider
25 changes: 15 additions & 10 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ Contents:
.. toctree::
:maxdepth: 2
:hidden:
:caption: API Documentation
:caption: Documentation

api

.. toctree::
:maxdepth: 2
:hidden:
:caption: Tutorial - Examples

auto_examples/index

.. toctree::
:maxdepth: 1
:hidden:
Expand All @@ -42,20 +49,18 @@ The exact API of all functions and classes, as given in the
doctring. The API documents expected types and allowed features for
all functions, and all parameters available for the algorithms.

`Examples <auto_examples/index.html>`_
--------------------------------------

A set of examples illustrating the use of the different algorithms. It
complements the `User Guide <user_guide.html>`_.

`What's new <whats_new.html>`_
------------------------------

Log of the scikit-cycling history.

`About imbalanced-learn <about.html>`_
`About scikit-cycling <about.html>`_
--------------------------------------

Just to know about history of scikit-cycling.


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
15 changes: 8 additions & 7 deletions doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ Getting Started
Install
-------

The install of ``scikit-cycling`` is almost straightforward. You need to clone it from GitHub_::
The install of ``scikit-cycling`` is almost straightforward. You need to clone
it from GitHub_::

$ git clone --recursive https://github.com/glemaitre/scikit-cycling.git
$ cd third-party/python-fitparse
$ python setup.py install
$ cd ../../
$ python setup.py install
$ git clone https://github.com/glemaitre/scikit-cycling.git
$ cd scikit-cycling
$ pip install .

Test and coverage
-----------------
Expand All @@ -26,6 +25,8 @@ You wish to test the coverage of your version::
Contribute
----------

You can contribute to this code through Pull Request on GitHub_. Please, make sure that your code is coming with unit tests to ensure full coverage and continuous integration in the API.
You can contribute to this code through Pull Request on GitHub_. Please, make
sure that your code is coming with unit tests to ensure full coverage and
continuous integration in the API.

.. _GitHub: https://github.com/glemaitre/scikit-cycling
35 changes: 35 additions & 0 deletions examples/plot_power_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
======================================
Workflow to exploit cycling power data
======================================
This example illustrates the typical workflow to use to investigate cycling
power data.
"""

# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Cedric Lemaitre
# License: BSD 3 clause

import matplotlib.pyplot as plt

from skcycling import Rider
# from skcycling.datasets import load_fit
from skcycling.datasets import load_rider

print(__doc__)

# rider = Rider(n_jobs=-1)
# rider.add_activities(load_fit())
rider = Rider.from_csv(load_rider())

rider.power_profile_.plot()
plt.xlabel('Time')
plt.ylabel('Power (W)')

rider.record_power_profile().plot(alpha=0.5, style='--', legend=True)
plt.xlabel('Time')
plt.ylabel('Power (W)')

plt.show()
Binary file removed manual.pdf
Binary file not shown.
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
scipy
numpy
pandas
joblib
scikit-learn
fitparse
six
cython

0 comments on commit 4d56123

Please sign in to comment.