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

Refactor for new PEP standard and pyproject.toml #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions .github/worflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
build:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.os == 'windows-latest' }}
strategy:
matrix:
os: [ubuntu-22.04, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install .
- name: Run Tests
run: |
python -m unittest --verbose
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# impala 0.1.9999
* refactor to new PEP standards

# impala 0.1
* initial version of package
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ pip install git+https://github.com/lanl/impala.git

## References

## Tests
```console
> python -m unittest
```

************

Expand Down
3 changes: 3 additions & 0 deletions impala/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .physical_models_vec import *
from .impala_noProbit_emu import *
from .models_withLik import *
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import numpy as np
import pyBASS as pb
#import pyBayesPPR as pbppr
#import physical_models_vec as pm_vec
from impala import physics as pm_vec
import impala.physical_models_vec as pm_vec
from itertools import cycle
from scipy.interpolate import interp1d
from scipy.linalg import cho_factor, cho_solve, cholesky
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion impala/physics/__init__.py

This file was deleted.

45 changes: 0 additions & 45 deletions impala/physics/test.py

This file was deleted.

File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions impala/superCal/__init__.py

This file was deleted.

38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[project]
name = "impala"
version = "0.1.0"
description = "Bayesian model calibration"
authors = [
{name = "Devin Francom", email = "[email protected]"},
{name = "Arthur Lui", email = "[email protected]"},
{name = "Peter Trubey", email = "[email protected]"},
{name = "J. Derek Tucker", email = "[email protected]"}
]
license = {text = "BSD 3-Clause"}
readme = "README.md"
requires-python = ">=3.6"

keywords = ["modelcalibration"]

dependencies=[
"numpy",
"matplotlib",
"scipy",
"pyBASS",
]

classifiers = [
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
]

[project.urls]
repository = "http://www.github.com/lanl/impala"

[tool.setuptools.packages.find]
exclude = ["data*", "tests*"]
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
numpy
pyBASS
scipy
matplotlib
20 changes: 0 additions & 20 deletions setup.py

This file was deleted.

Empty file added tests/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions tests/img/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
52 changes: 52 additions & 0 deletions tests/test_physics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import unittest
import numpy as np
from impala import physical_models_vec as physics
import matplotlib.pyplot as plt

class TestPhysics(unittest.TestCase):
def test_physics(self):
consts = {
'alpha' : 0.2,
'beta' : 0.33,
'matomic': 45.9,
'Tmelt0' : 2110.,
'rho0' : 4.419,
'Cv0' : 0.525e-5,
'G0' : 0.4,
'chi' : 1.0,
'sgB' : 6.44e-4
}

params = {
'theta' : np.array([0.1]),
'p' : np.array([2.]),
's0' : np.array([0.02]),
'sInf' : np.array([0.01]),
'kappa' : np.array([0.3]),
'lgamma' : np.array([-12.]),
'y0' : np.array([0.01]),
'yInf' : np.array([0.003]),
'y1' : np.array([0.09]),
'y2' : np.array([0.7]),
}

ptw = physics.MaterialModel(
flow_stress_model=physics.PTW_Yield_Stress, shear_modulus_model=physics.Stein_Shear_Modulus,
)

edot = 2500 * 1e-6 # 2500/s
temp = 1000 # K
emax = 0.6
nhist = 100
sim_strain_histories = physics.generate_strain_history_new(emax=np.array([emax]), edot=np.array([edot]), nhist=nhist)
ptw.initialize(params, consts)
ptw.initialize_state(T = np.array([temp]), stress = np.zeros(1), strain = np.zeros(1))
sim_state_histories = ptw.compute_state_history(sim_strain_histories)
sim_strains = sim_state_histories[:,1].T # 2d array: ntot, Nhist
sim_stresses = sim_state_histories[:,2].T # 2d array: ntot, Nhist

img_path = "tests/img/sim-stresses.png"
plt.plot(sim_strains.T, sim_stresses.T)
plt.savefig(img_path)
plt.close()
print(f"Image saved to {img_path}")