Skip to content

Commit

Permalink
Merge pull request #8 from jngaravitoc/main
Browse files Browse the repository at this point in the history
Restructure
  • Loading branch information
jngaravitoc authored Nov 21, 2023
2 parents c9f7a70 + 5f363d8 commit 52af8c7
Show file tree
Hide file tree
Showing 19 changed files with 875 additions and 187 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: "Test Ubuntu Build"

on:
push:
branches:
- main
pull_request:

jobs:
pyexp:
strategy:
matrix:
os: [ubuntu-latest]
cc: [gcc, mpicc]

name: "Test pyEXP Build"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install core dependencies - ubuntu
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential libeigen3-dev libfftw3-dev libhdf5-dev libopenmpi-dev
- name: Setup submodule and build
run: |
git submodule update --init --recursive
mkdir -p build/install
- name: Compile pyEXP - Linux
if: runner.os == 'Linux'
env:
CC: ${{ matrix.cc }}
working-directory: ./build
run: >-
cmake
-DENABLE_NBODY=NO
-DENABLE_PYEXP=YES
-DCMAKE_BUILD_TYPE=Release
-DEigen3_DIR=/usr/include/eigen3/share/eigen3/cmake
-DCMAKE_INSTALL_PREFIX=./install
-Wno-dev
..
- name: Make
working-directory: ./build
run: make -j 2

# -----------------------------------------------------------------------------------

exp:
strategy:
matrix:
os: [ubuntu-latest]
cc: [gcc, mpicc]

name: "Test Full EXP Build"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install core dependencies - ubuntu
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential libeigen3-dev libfftw3-dev libhdf5-dev libopenmpi-dev
- name: Setup submodule and build
run: |
git submodule update --init --recursive
mkdir -p build/install
- name: Compile Full EXP - Linux
if: runner.os == 'Linux'
env:
CC: ${{ matrix.cc }}
working-directory: ./build
run: >-
cmake
-DENABLE_NBODY=YES
-DENABLE_PYEXP=NO
-DCMAKE_BUILD_TYPE=Release
-DEigen3_DIR=/usr/include/eigen3/share/eigen3/cmake
-DCMAKE_INSTALL_PREFIX=./install
-Wno-dev
..
- name: Make
working-directory: ./build
run: make -j 2
41 changes: 41 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- 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
# Tests not working at the moment -- pyEXP requirement!
#- name: Test with pytest
# run: |
# pytest
3 changes: 0 additions & 3 deletions EXP_tools/__init__.py

This file was deleted.

172 changes: 0 additions & 172 deletions EXP_tools/makemodel.py

This file was deleted.

2 changes: 2 additions & 0 deletions EXPtools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import visuals
from . import basis_builder
5 changes: 5 additions & 0 deletions EXPtools/basis_builder/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import makemodel
from . import profiles
from .makemodel import makemodel
from .profiles import Profiles
from .basis_utils import makebasis
21 changes: 13 additions & 8 deletions EXP_tools/basis_utils.py → EXPtools/basis_builder/basis_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os, sys, pickle, pyEXP
import numpy as np
import makemodel
from makemodel import hernquist_halo
from . import makemodel

def make_config(basis_id, numr, rmin, rmax, lmax, nmax, scale,
modelname='', cachename='.slgrid_sph_cache'):
Expand Down Expand Up @@ -206,9 +205,9 @@ def make_exp_basis_table(radius, density, outfile='', plabel='',
return rvals*rfac, dfac*dvals, mfac*mvals, pfac*pvals


def make_a_BFE(pos, mass, config=None, basis_id='sphereSL', time=0,
def makebasis(pos, mass, basis_model, config=None, basis_id='sphereSL', time=0,
numr=500, rmin=0.61, rmax=599, lmax=4, nmax=20, scale=22.5,
modelname='dens_table.txt', cachename='.slgrid_sph_cache', add_coef = False, coef_file='', empirical=False):
modelname='dens_table.txt', cachename='.slgrid_sph_cache', add_coef = False, coef_file=''):
"""
Create a BFE expansion for a given set of particle positions and masses.
Expand All @@ -217,6 +216,7 @@ def make_a_BFE(pos, mass, config=None, basis_id='sphereSL', time=0,
and each column represents the coordinate of that particle.
mass (numpy.ndarray): The masses of particles. The length of this array should be the same
as the number of particles.
basismodel ():
config (pyEXP.config.Config, optional): A configuration object that specifies the basis set.
If not provided, an empirical density profile will be computed
and a configuration object will be created automatically.
Expand All @@ -239,16 +239,20 @@ def make_a_BFE(pos, mass, config=None, basis_id='sphereSL', time=0,
The basis is an instance of pyEXP.basis.Basis, and the coefficients are
an instance of pyEXP.coefs.Coefs.
"""

"""
if os.path.isfile(modelname) == False:
print("-> File model not found so we are computing one \n")
if empirical == True:
print('-> Computing empirical model')
rad, rho = empirical_density_profile(pos, mass, nbins=numr)
R, D, M, P = makemodel_empirical(r_exact, rho, outfile=modelname, return_values=True)
elif empirical == False:
makemodel.hernquist_halo()
makemodel.Profiles(density_profile)
R, D, M, P = makemodel.makemodel(rvals=np.logspace(np.log10(rmin), np.log10(rmax), numr), rho, outfile=modelname, return_values=True)
print('-> Computing analytical Hernquist model')
R, D, M, P = makemodel.makemodel(hernquist_halo, 1, [scale], rvals=np.logspace(np.log10(rmin), np.log10(rmax), numr), pfile=modelname)
R, D, M, P = makemodel.makemodel(hernquist_halo, 1, [scale], rvals=, pfile=modelname)
print('-> Model computed: rmin={}, rmax={}, numr={}'.format(R[0], R[-1], len(R)))
else:
R, D, M, P = np.loadtxt(modelname, skiprows=3, unpack=True)
Expand Down Expand Up @@ -278,4 +282,5 @@ def make_a_BFE(pos, mass, config=None, basis_id='sphereSL', time=0,
coefs.ExtendH5Coefs(coef_file)
return basis, coefs

"""
return None
Loading

0 comments on commit 52af8c7

Please sign in to comment.