Skip to content

Commit

Permalink
build-n-test-before-deploy (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
o-murphy authored Dec 22, 2023
1 parent 6802365 commit e002208
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/python-publish-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,60 @@ permissions:
contents: read

jobs:

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

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: |
sudo apt-get update
sudo apt-get install build-essential -y
python -m pip install --upgrade pip
python -m pip install setuptools pytest cython
- name: Run unittest tests in pure python mode
run: |
if pytest tests --no-header --no-summary -v; then
echo "Pytest succeeded."
else
echo "Pytest failed, running without capture"
# Add your additional commands here
pytest tests --no-header --no-summary -v -s
fi
- name: Build cython modules
run: |
cd py_ballisticcalc_exts
python setup.py build_ext --inplace
cd ..
- name: Run unittest tests in binary mode
run: |
if pytest tests --no-header --no-summary -v; then
echo "Pytest succeeded."
else
echo "Pytest failed, running without capture"
# Add your additional commands here
pytest tests --no-header --no-summary -v -s
fi


deploy:
needs: build
runs-on: ${{ matrix.os }}

strategy:
Expand Down
68 changes: 68 additions & 0 deletions examples/ukrop_338lm_300gr_smk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""Example of library usage"""

from py_ballisticcalc import *
from py_ballisticcalc import Settings as Set

# set global library settings
Set.Units.velocity = Velocity.MPS
Set.Units.adjustment = Unit.CM_PER_100M
Set.Units.temperature = Temperature.Celsius
# Set.Units.distance = Distance.Meter
Set.Units.sight_height = Distance.Centimeter
Set.Units.distance = Distance.Meter

# Set.set_max_calc_step_size(Distance.Foot(1))
Set.USE_POWDER_SENSITIVITY = True # enable muzzle velocity correction my powder temperature

# define params with default units
weight, diameter = 300, 0.338
# or define with specified units
length = Distance.Inch(1.7) # length = Distance(1.282, Distance.Inch)

weapon = Weapon(twist=10, zero_distance=Distance.Meter(100),
sight_height=Unit.CENTIMETER(9))
dm = DragModel(0.381, TableG7, weight, diameter)

ammo = Ammo(
dm=dm, length=length,
mv=Unit.MPS(815),
powder_temp=Unit.CELSIUS(0))

# ammo.calc_powder_sens(
# other_velocity=Unit.MPS(800),
# other_temperature=Unit.CELSIUS(-22)
# )
# print(ammo.temp_modifier)
ammo.temp_modifier = 0.0123

# zero_atmo = Atmo.icao(100)
zero_atmo = Atmo(
altitude=Unit.METER(150),
pressure=Unit.MM_HG(745),
temperature=Unit.CELSIUS(-1),
humidity=78
)

# defining calculator instance
calc = Calculator(weapon, ammo, zero_atmo)

current_atmo = Atmo(
altitude=Unit.METER(150),
pressure=Unit.HP(992),
temperature=Unit.CELSIUS(23),
humidity=29
)

current_winds = [Wind()]
shot = Shot(Distance.Meter(1000), atmo=current_atmo, winds=current_winds)

shot_result = calc.fire(shot, Distance.Meter(100))

from pprint import pprint
fieldsss = TrajectoryData._fields

for p in shot_result:

table = [{fieldsss[i]: it} for i, it in enumerate(p.formatted())]

pprint(table)

0 comments on commit e002208

Please sign in to comment.