Skip to content

Commit

Permalink
Fix not extra dataframe (#44)
Browse files Browse the repository at this point in the history
* fix_not_extra_dataframe
  • Loading branch information
o-murphy authored Dec 27, 2023
1 parent e002208 commit bc0e2dd
Show file tree
Hide file tree
Showing 7 changed files with 320 additions and 15 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,58 @@ 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
80 changes: 68 additions & 12 deletions Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"execution_count": 1,
"metadata": {
"pycharm": {
"is_executing": true
"is_executing": true,
"name": "#%%\n"
}
},
"outputs": [
Expand All @@ -32,7 +33,11 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -57,7 +62,11 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -96,7 +105,11 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -118,7 +131,11 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -156,7 +173,11 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"shot_result.dataframe.to_clipboard()"
Expand All @@ -169,6 +190,9 @@
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
Expand All @@ -181,6 +205,9 @@
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
Expand All @@ -193,6 +220,9 @@
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
Expand All @@ -205,6 +235,9 @@
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
Expand All @@ -217,6 +250,9 @@
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
Expand All @@ -225,35 +261,55 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": []
}
Expand All @@ -279,4 +335,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
177 changes: 177 additions & 0 deletions examples/canik_50bmg.ipynb

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions examples/canik_50bmg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from py_ballisticcalc import Unit
from py_ballisticcalc import DragModel, TableG1
from py_ballisticcalc import Ammo
from py_ballisticcalc import Weapon, Shot, Calculator
from py_ballisticcalc import Settings as Set

Set.Units.distance = Unit.METER
Set.Units.velocity = Unit.MPS
Set.Units.sight_height = Unit.CENTIMETER

dm = DragModel(0.62, TableG1, 661, 0.51)
ammo = Ammo(dm, 2.3, 837)

weapon = Weapon(9, 500, 15, Unit.DEGREE(30))
calc = Calculator(weapon, ammo)
zero_elevation = calc.elevation
print(f'Barrel elevation for zero: {zero_elevation << Unit.MIL}')

shot = Shot(3000, zero_angle=calc.elevation, relative_angle=Unit.MIL(0))
shot_result = calc.fire(shot, 100, extra_data=False)
shot_result.dataframe.to_clipboard()
2 changes: 1 addition & 1 deletion py_ballisticcalc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__copyright__ = ("",)

__credits__ = ["o-murphy"]
__version__ = "1.1.2"
__version__ = "1.1.3"


from .backend import *
Expand Down
2 changes: 1 addition & 1 deletion py_ballisticcalc/trajectory_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def dataframe(self):
""":return: the trajectory table as a DataFrame"""
if pd is None:
raise ImportError("Install pandas to get trajectory as dataframe")
self.__check_extra__()
# self.__check_extra__()
col_names = list(TrajectoryData._fields)
trajectory = [p.in_def_units() for p in self]
return pd.DataFrame(trajectory, columns=col_names)
Expand Down
2 changes: 1 addition & 1 deletion py_ballisticcalc_exts/py_ballisticcalc_exts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__copyright__ = ("",)

__credits__ = ["o-murphy"]
__version__ = "1.1.2"
__version__ = "1.1.3"

from .drag_model import *
from .trajectory_calc import *

0 comments on commit bc0e2dd

Please sign in to comment.