Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #19 from fjhheras/develop
Browse files Browse the repository at this point in the history
Merging develop into master. Preparing v. 0.3.2
  • Loading branch information
fjhheras committed Jul 11, 2020
2 parents 2230eb5 + f1efbfc commit 7c4205b
Show file tree
Hide file tree
Showing 32 changed files with 1,593 additions and 725 deletions.
80 changes: 80 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# trajectorytools Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting any member of the core project team:

- francisco.heras@neuro.fchampalimaud.org (Francisco J. H. Heras)
- francisco.romero@neuro.fchampalimaud.org (Francisco Romero Ferrero)

All complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
32 changes: 32 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Contributing to trajectorytools

## Reporting issues

When reporting issues please include as much detail as possible about your
operating system, trajectorytools version and python version. Whenever
possible, please also include a brief, self-contained code example
demonstrating the problem.

## Contributing code

Thanks for your interest in contributing code to trajectorytools!

We gladly welcome pull requests, normally to the develop branch.

We try very hard to follow good coding practices. This includes:

+ We do not add commits directly to master and develop, only pull requests
+ We follow [PEP 8 recommendations](https://www.python.org/dev/peps/pep-0008/),
including the line length limit of 79 for python code and 72 for docs/comments.
+ We use an autoformatter called [black](https://github.com/psf/black) to have
a uniform code look. Before submitting pull requests, we would appreciate if
you autoformat the code using the following command: `black -l 79 .`
+ Whenever possible, we create tests for any new code.

If you are like us some years ago and have problems following these rules,
we are happy to help you implement them during the pull request process.

## Attribution

This CONTRIBUTING file is highly influenced by the contributing guidelines in
[numpy](https://github.com/numpy/numpy/edit/master/.github/CONTRIBUTING.md)
18 changes: 13 additions & 5 deletions .github/workflows/pythonpackage_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,23 @@ jobs:
- name: Install
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
pip install black flake8 pytest pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
- name: Check format with black
run: |
black -l 79 --check .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# stop the build if there are Python syntax errors, deprecations or undefined names
# our line length is 79 (72 for docstrings), and we are strict (stop) if above 88
flake8 . --count --select=E5,E9,W6,F63,F7,F82 --max-line-length=88 --show-source --statistics
# exit-zero treats all errors as warnings.
# ignoring when clashing with black:
# - W503 line break before binary operator
# - E203 whitespace before ':'
# - C0330 Wrong hanging indentation before block
flake8 . --count --exit-zero --max-complexity=10 --statistics --ignore=E203,W503,C0330
- name: Generate coverage report
run: |
pip install pytest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ docs/_build
.vscode

\.idea/

# Type checking stuff
.mypy_cache/
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ Francisco Romero Ferrero (2017-)
Contribute
==========

Please.
We welcome contributions. The preferred way to report problems is by creating an issue. The best way to propose changes in the code is to create a pull request. Please, check our `contribution guidelines`_ and our `code of conduct`_.

.. _contribution guidelines: .github/CONTRIBUTING.md
.. _code of conduct: .github/CODE_OF_CONDUCT.md


License
=======
Expand Down
54 changes: 24 additions & 30 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
from setuptools import setup, find_packages
from setuptools import find_packages, setup

with open("README.rst", "r") as fh:
long_description = fh.read()

setup(name='trajectorytools',
version='0.3.1-alpha',
description='A tool to study 2D trajectories',
long_description=long_description,
url='http://github.com/fjhheras/trajectorytools',
author='Francisco J.H. Heras',
author_email='fjhheras@gmail.com',
license='GPL',

install_requires=['MiniballCpp',
'matplotlib',
'scikit-learn',
'scipy'],

packages=find_packages(),
package_data={'trajectorytools': ['data/*.npy']},
include_package_data=True,
zip_safe=False,

classifiers=[
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Software Development :: Libraries',
'Topic :: Utilities'
],

)
setup(
name="trajectorytools",
version="0.3.2-alpha",
description="A tool to study 2D trajectories",
long_description=long_description,
url="http://github.com/fjhheras/trajectorytools",
author="Francisco J.H. Heras, Francisco Romero Ferrero",
author_email="fjhheras@gmail.com",
license="GPL",
install_requires=["MiniballCpp", "matplotlib", "scikit-learn", "scipy"],
packages=find_packages(),
package_data={"trajectorytools": ["data/*.npy"]},
include_package_data=True,
zip_safe=False,
classifiers=[
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
],
)
27 changes: 13 additions & 14 deletions tests/collective_test.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import pytest
import numpy as np
import pytest

import trajectorytools as tt
import trajectorytools.constants as cons
from trajectorytools.collective import (angular_momentum,
polarization)
from trajectorytools.collective import angular_momentum, polarization
from trajectorytools.geometry import center_in_trajectory
import trajectorytools as tt


class TestExtremeCases():
class TestExtremeCases:
def setup_class(self):
v = np.random.randn(50, 2)
self.v_same = np.stack([v]*10, axis=1)
self.v_same = np.stack([v] * 10, axis=1)
self.v_antiparallel = self.v_same.copy()
self.v_antiparallel[:, ::2, :] *= -1

Expand All @@ -23,17 +22,18 @@ def test_pol_antiparallel(self):
pol = tt.norm(polarization(self.v_antiparallel))
assert pytest.approx(pol, 1e-16) == 0

@pytest.mark.parametrize('num_dims_point', [2, 1])
@pytest.mark.parametrize("num_dims_point", [2, 1])
def test_ang_mom_antiparallel(self, num_dims_point):
# Random point to measure angular momentum
if num_dims_point == 2:
point = np.random.randn(2)
elif num_dims_point == 1:
point = np.random.randn(50, 2)
# Random locations (but all in the same point)
locations = np.stack([np.random.randn(50, 2)]*10, axis=1)
ang_momentum = tt.norm(angular_momentum(
self.v_antiparallel, locations))
locations = np.stack([np.random.randn(50, 2)] * 10, axis=1)
ang_momentum = tt.norm(
angular_momentum(self.v_antiparallel, locations, center=point)
)
assert pytest.approx(ang_momentum, 1e-16) == 0

@pytest.fixture(autouse=True)
Expand All @@ -46,7 +46,7 @@ def run_around_tests(self):
assert np.all(v_antiparallel == self.v_antiparallel)


class TestAngularMomentum():
class TestAngularMomentum:
def setup_class(self):
self.v = np.random.randn(50, 10, 2)
self.s = np.random.randn(50, 10, 2)
Expand All @@ -70,9 +70,8 @@ def test_theorem_center_of_mass(self):
np.testing.assert_almost_equal(L_1, L_1_b)

L_2 = num_individuals * angular_momentum(
V[:, np.newaxis, :],
S[:, np.newaxis, :],
self.p)
V[:, np.newaxis, :], S[:, np.newaxis, :], self.p
)

# angular momentum around a point is the sum of the angular
# momentum around the center of mass and the angular momentum
Expand Down
Loading

0 comments on commit 7c4205b

Please sign in to comment.