diff --git a/.github/workflows/python-publish-test.yml b/.github/workflows/python-publish-test.yml index 05b40a8..368cb7b 100644 --- a/.github/workflows/python-publish-test.yml +++ b/.github/workflows/python-publish-test.yml @@ -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: diff --git a/examples/ukrop_338lm_300gr_smk.py b/examples/ukrop_338lm_300gr_smk.py new file mode 100644 index 0000000..0ceae89 --- /dev/null +++ b/examples/ukrop_338lm_300gr_smk.py @@ -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)