Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pipit docs and add tests #23

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: UIPS-CI

Check failure on line 1 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / Lint (3.10, ubuntu-latest)

.github/workflows/ci.yml#L1

This run was manually canceled.

on:
push:
Expand All @@ -7,20 +7,48 @@
- '*.md'
- 'README*'
- 'LICENSE'
- 'documentation/readmeImages/*'
pull_request:
branches: [main]
paths-ignore:
- '*.md'
- 'README*'
- 'LICENSE'
- 'documentation/readmeImages/*'

jobs:
UIPS:
Lint:
name: Lint (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.10']
os: ['ubuntu-latest']
defaults:
run:
working-directory: ${{github.workspace}}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{matrix.python-version}}
- name: Install dependencies
run: |
pip install black
pip install isort
pip install codespell
- name: Formatting and sorting import
run: |
source .github/linters/formatting.sh
format . true
Test:
name: Test (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12']
mpi: ['openmpi']
defaults:
run:
Expand All @@ -40,15 +68,7 @@
run: |
python -m pip install --upgrade pip
python -m pip install .
pip install black
pip install isort
pip install codespell
pip install pytest
- name: Formatting
run: |
source .github/linters/formatting.sh
format . true
codespell
- name: Pytests
run: |
python -m pytest tests -v --disable-warnings
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Phase-space sampling of large datasets [![UIPS-CI](https://github.com/NREL/Phase-space-sampling/actions/workflows/ci.yml/badge.svg)](https://github.com/NREL/Phase-space-sampling/actions/workflows/ci.yml) [![UIPS-pypi](https://badge.fury.io/py/uips.svg)](https://badge.fury.io/py/uips)
# Phase-space sampling of large datasets [![UIPS-CI](https://github.com/NREL/Phase-space-sampling/actions/workflows/ci.yml/badge.svg)](https://github.com/NREL/Phase-space-sampling/actions/workflows/ci.yml) [![UIPS-pyversion](https://img.shields.io/pypi/pyversions/uips.svg)](https://pypi.org/project/uips/) [![UIPS-pypi](https://badge.fury.io/py/uips.svg)](https://badge.fury.io/py/uips)

## Installation for NREL HPC users
1. `module load openmpi/4.1.0/gcc-8.4.0`
Expand Down Expand Up @@ -123,22 +123,22 @@ A script is provided to visualize the losses. Execute `python plotLoss.py -i inp
Suppose one wants to downsample an dataset where $N=10^7$ and $d=2$. First, the code estimates the probability map of the data in order to identify where are located redundant data points. An example dataset (left) and associated probability map (right) are shown below

<p float="left">
<img src="documentation/readmeImages/fulldataset.png" width="350"/>
<img src="documentation/readmeImages/probabilityMap.png" width="350"/>
<img src="https://raw.githubusercontent.com/NREL/Phase-space-sampling/main/documentation/readmeImages/fulldataset.png" width="350"/>
<img src="https://raw.githubusercontent.com/NREL/Phase-space-sampling/main/documentation/readmeImages/probabilityMap.png" width="350"/>
</p>

Next, the code uses the probability map to define a sampling probability which downselect samples that uniformly span the feature space. The probability map is obtained by training a Neural Spline Flow which implementation was obtained from [Neural Spline Flow repository](https://github.com/bayesiains/nsf). The number of samples in the final dataset can be controlled via the input file.

<p float="left">
<img src="documentation/readmeImages/103_uips.png" width="350"/>
<img src="documentation/readmeImages/104_uips.png" width="350"/>
<img src="https://raw.githubusercontent.com/NREL/Phase-space-sampling/main/documentation/readmeImages/103_uips.png" width="350"/>
<img src="https://raw.githubusercontent.com/NREL/Phase-space-sampling/main/documentation/readmeImages/104_uips.png" width="350"/>
</p>

For comparison, a random sampling gives the following result

<p float="left">
<img src="documentation/readmeImages/103_randomSampling.png" width="350"/>
<img src="documentation/readmeImages/104_randomSampling.png" width="350"/>
<img src="https://raw.githubusercontent.com/NREL/Phase-space-sampling/main/documentation/readmeImages/103_randomSampling.png" width="350"/>
<img src="https://raw.githubusercontent.com/NREL/Phase-space-sampling/main/documentation/readmeImages/104_randomSampling.png" width="350"/>
</p>

## Example 11D
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
openmpi
torch
numpy
mpi4py
scikit-learn
prettyPlot>=0.0.25
prettyPlot>=0.0.27
29 changes: 21 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
import os

from setuptools import setup

here = os.path.abspath(os.path.dirname(__file__))

with open(os.path.join(here, "requirements.txt")) as f:
install_requires = f.readlines()

with open(os.path.join(here, "README.md"), encoding="utf-8") as f:
readme = f.read()

with open(os.path.join(here, "uips", "version.py"), encoding="utf-8") as f:
version = f.read()
version = version.split("=")[-1].strip().strip('"').strip("'")


setup(
name="uips",
version="0.1.0",
version=version,
description="Reduce a large and high-dimensional dataset by downselecting data uniformly in phase space",
long_description=readme,
long_description_content_type="text/markdown",
url="https://github.com/NREL/Phase-space-sampling",
author="Malik Hassanaly",
license="BSD 3-Clause",
Expand All @@ -13,15 +30,11 @@
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
package_data={"": ["input2D", "input2D_bins"]},
include_package_data=True,
python_requires=">=3.10",
install_requires=[
"torch",
"numpy",
"mpi4py",
"scikit-learn",
"prettyPlot>=0.0.25",
],
install_requires=install_requires,
)
2 changes: 1 addition & 1 deletion uips/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""UIPS version"""

__version__ = "0.1.0"
__version__ = "0.1.1"
Loading