Skip to content

Commit

Permalink
Merge branch 'develop' into jprince127-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
hackdna authored Dec 13, 2024
2 parents 01cada8 + 45fb410 commit 0c44fc1
Show file tree
Hide file tree
Showing 138 changed files with 129 additions and 126 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
exclude = .venv
10 changes: 3 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@ jobs:
if: ${{ startsWith(matrix.os, 'windows') }}
uses: FedericoCarboni/setup-ffmpeg@v3
id: setup-ffmpeg
- name: Install Forest
run: pip install -e .
- name: Install dev dependencies
run: pip install -r requirements.txt
- name: Install Forest and optional development dependencies
run: pip install -e ".[dev]"
- name: Run code style checking
run: flake8
- name: Run static type checking
run: mypy -p forest
- name: Run legacy tests
run: python -m unittest tests/imports.py
- name: Run pytest suite
- name: Run the test suite
run: pytest
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
__pycache__/
dist/
forest_analysis.egg-info/

.vagrant/
.venv/
venv/
.DS_Store

# IntelliJ, VsCode project files
.idea
.vscode

# for installing Forest in editable mode when developing
/forest.egg-info/
.idea/
.vscode/

#We don't want to add data to github
/tutorials/data/
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[![build](https://github.com/onnela-lab/forest/actions/workflows/build.yml/badge.svg)](https://github.com/onnela-lab/forest/actions/workflows/build.yml)
[![Documentation Status](https://readthedocs.org/projects/forest-docs/badge/)](https://forest.beiwe.org/en/latest/)

<img width="264" height="99" src="forest-logo-color.png" alt="Forest logo">
<!--- using a URL to display logo on PyPI --->
<img width="264" height="99" src="https://raw.githubusercontent.com/onnela-lab/forest/main/forest-logo-color.png" alt="Forest logo">

The Onnela Lab at the Harvard T.H. Chan School of Public Health has developed the Forest library to analyze smartphone-based high-throughput digital phenotyping data. The main intellectual challenge in smartphone-based digital phenotyping has moved from data collection to data analysis. Our research focuses on the development of mathematical and statistical methods for analyzing intensive high-dimensional data. We are actively developing the Forest library for analyzing smartphone-based high-throughput digital phenotyping data collected with the [Beiwe](https://github.com/onnela-lab/beiwe-backend) platform. Forest will implement our methods for analyzing Beiwe data as a Python package and is released under the BSD-3 open-source license. The Forest library will continue to grow over the coming years as we develop new analytical methods.

Forest can be run locally but is also integrated into the Beiwe back-end on AWS, consistent with the preferred big-data computing paradigm of moving computation to the data. Integrated with Beiwe, Forest can be used to generate on-demand analytics, most importantly daily or hourly summary statistics of collected data, which are stored in a relational database on AWS. The system also implements an API for Tableau, which supports the creation of customizable workbooks and dashboards to view data summaries and troubleshoot any issues with data collection. Tableau is commercial software but is available under free viewer licenses and may be free to academic users for the first year (see Tableau for more information).

For more detailed info on specific subpackages, see our [Documentation](https://forest.beiwe.org). Please note that Forest uses Python 3.11.
For more detailed info on specific subpackages, see our [Documentation](https://forest.beiwe.org).

# Description

Expand All @@ -30,13 +31,13 @@ Output: typically summary files

# Usage

To install, clone this repository to a local directory and then:
Please note that Forest uses Python 3.11. To install, clone this repository to a local directory and then:

```console
pip install path/to/forest
```

Alternatively, [install directly from github](https://pip.pypa.io/en/stable/reference/pip_install/#git) with `pip`. As the repo is public, it won't prompt you to login. If you've used forest in the past, it might be prudent to do a '''pip uninstall forest''' first.
Alternatively, [install directly from GitHub](https://pip.pypa.io/en/stable/cli/pip_install/#examples) with `pip`. As the repo is public, it won't prompt you to login. If you've used forest in the past, it might be prudent to do a `pip uninstall forest` first.

```console
pip install git+https://github.com/onnela-lab/forest
Expand All @@ -46,7 +47,7 @@ To immediately test out forest, adapt the filepaths in the code below and run:

```python
# Currently, all imports from `forest` must be explicit. For the below example you need to import the following
# In future, it would be great to have all functions import automatically
# In the future, it would be great to have all functions import automatically
import datetime

from forest.bonsai.simulate_log_data import sim_log_data
Expand Down
22 changes: 19 additions & 3 deletions docs/source/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ Information for contributors

## Quick start
* Change current directory to the top level of your local Forest repository
* Install Forest in editable mode: `pip install -e .`
* Install development tools: `pip install -r requirements.txt`
* Install Forest in editable mode along with development tools: `pip install -e ".[dev]"`
* Run code style checks: `flake8`
* Run type hint checks: `mypy -p forest`
* Run type hint checks: `mypy`
* Run test suite: `pytest`

### Documentation
Expand Down Expand Up @@ -44,6 +43,23 @@ Open `docs/_build/html/index.html` in a web browser to check the results
* Use the [logging module](https://docs.python.org/3/library/logging.html) instead of `print()`
* [Formatting log messages](http://reinout.vanrees.org/weblog/2015/06/05/logging-formatting.html): `logger.info("%s went %s wrong", 42, 'very')`
* Continue writing code and comments all the way until the end of the line then indent appropriately
* [Packaging Python Projects](https://packaging.python.org/en/latest/tutorials/packaging-projects)

### Packaging and distribution

#### Python Package Index
* Use [TestPyPI](https://test.pypi.org/) for testing that your package can be uploaded, downloaded, and installed correctly
* [Register an account](https://test.pypi.org/account/register/)
* [Create an API token](https://test.pypi.org/manage/account/#api-tokens) (setting the "Scope" to "Entire account")
* [Add API token](https://packaging.python.org/en/latest/specifications/pypirc/#using-a-pypi-token) to your `$HOME/.pypirc` file
* Generate distribution archives: `python -m build`
* Check the results: `twine check dist/*`
* Upload distribution archives:
* TestPyPI: `twine upload --repository testpypi dist/*`
* PyPI: `twine upload dist/*`
* Install from TestPyPI to verify:
* TestPyPI: `pip install --index-url https://test.pypi.org/simple/ --no-deps forest-analysis`
* PyPI: `pip install forest-analysis`

## GitHub

Expand Down
Empty file removed forest/poplar/raw/__init__.py
Empty file.
Empty file removed forest/willow/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[mypy]
mypy_path = src
packages = forest
python_version = 3.11

[mypy-holidays]
Expand Down
71 changes: 71 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "forest-analysis"
version = "1.0.dev3"
description = "Forest is a library for analyzing smartphone-based high-throughput digital phenotyping data"
authors = [
{ name = "Onnela Lab", email = "[email protected]" }
]
maintainers = [
{ name = "Onnela Lab", email = "[email protected]" }
]
readme = "README.md"
license = { text = "BSD-3-Clause" }
requires-python = ">=3.11"
dependencies = [
"holidays",
"librosa",
"numpy",
"openrouteservice",
"pandas",
"pyproj",
"python-dateutil",
"pytz",
"ratelimit",
"requests",
"scipy",
"shapely",
"ssqueezepy",
"timezonefinder",
]
keywords = ["digital phenotyping", "smartphone", "statistics", "accelerometer", "GPS"]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Information Analysis",
]

[project.urls]
Documentation = "https://forest.beiwe.org"
Homepage = "https://github.com/onnela-lab/forest"
Issues = "https://github.com/onnela-lab/forest/issues"
Source = "https://github.com/onnela-lab/forest"

[project.optional-dependencies]
dev = [
"build",
"flake8",
"flake8-pytest-style",
"mypy",
"pytest",
"pytest-mock",
"twine",
"types-python-dateutil",
"types-pytz",
"types-requests",
"types-setuptools",
]

[tool.setuptools.package-data]
"forest.poplar.raw" = ["noncode/*.csv", "noncode/*.json"]
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[pytest]
addopts = --import-mode=importlib
testpaths = tests
filterwarnings =
error
# Ignore specific DeprecationWarnings from librosa.core.intervals
Expand Down
9 changes: 0 additions & 9 deletions requirements.txt

This file was deleted.

39 changes: 0 additions & 39 deletions setup.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed tests/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def test_get_path_close_locations(coords1, coords3):
== 2)


@pytest.fixture()
@pytest.fixture
def random_path(directions1, coords1, coords2):
lat1, lon1 = coords1
lat2, lon2 = coords2
Expand Down Expand Up @@ -507,7 +507,7 @@ def test_person_office_days(sample_coordinates, sample_locations,
assert len(random_person.office_days) <= 5


@pytest.fixture()
@pytest.fixture
def sample_person(sample_coordinates, sample_locations, sample_attributes):
user_attrs = sample_attributes["User 5"]
attributes = Attributes(**user_attrs)
Expand Down Expand Up @@ -804,7 +804,7 @@ def test_gen_all_traj_dist_travelled(sample_person, mocker):
assert np.all(total_d_list >= 0)


@pytest.fixture()
@pytest.fixture
def generated_trajectory(sample_person, mocker):
mocker.patch(
"forest.bonsai.simulate_gps_data.get_path", side_effect=mock_get_path
Expand Down Expand Up @@ -869,7 +869,7 @@ def test_load_attributes_switches(sample_attributes):
assert switches[5]["travelling_status-20"] == 1


@pytest.fixture()
@pytest.fixture
def sample_addresses():
return np.array(
[
Expand Down
41 changes: 0 additions & 41 deletions tests/imports.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
)


@pytest.fixture()
@pytest.fixture
def coords1():
return 51.457183, -2.597960


@pytest.fixture()
@pytest.fixture
def coords2():
return 51.457267, -2.598045

Expand Down Expand Up @@ -54,7 +54,7 @@ def test_transform_point_to_circle_radius(coords1):
assert 4 <= distance <= 5


@pytest.fixture()
@pytest.fixture
def sample_trajectory():
"""16 minutes of a random trajectory"""
return np.array(
Expand Down Expand Up @@ -153,7 +153,7 @@ def sample_trajectory():
)


@pytest.fixture()
@pytest.fixture
def sample_nearby_locations():
ids = {
"post_box": [560374554],
Expand Down Expand Up @@ -480,7 +480,7 @@ def test_gps_summaries_pcr(
assert summary["physical_circadian_rhythm_stratified"].iloc[1] == 0


@pytest.fixture()
@pytest.fixture
def mobmat1():
"""mobility matrix 1"""
return np.array(
Expand All @@ -494,7 +494,7 @@ def mobmat1():
)


@pytest.fixture()
@pytest.fixture
def mobmat2():
"""mobility matrix 2"""
return np.array(
Expand All @@ -508,7 +508,7 @@ def mobmat2():
)


@pytest.fixture()
@pytest.fixture
def mobmat3():
"""mobility matrix 3"""
return np.array(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 0c44fc1

Please sign in to comment.