Skip to content

Commit

Permalink
Changed the naming of files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-Palmroos committed Dec 16, 2024
1 parent 03d97fc commit 09a9c50
Show file tree
Hide file tree
Showing 16 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest -rP --mpl --mpl-baseline-path=baseline --mpl-baseline-relative --mpl-generate-summary=html --mpl-results-path='/home/runner/work/bowtie/Bowtie/tests/report/' --cov=Bowtie Bowtie/tests/test.py
pytest -rP --mpl --mpl-baseline-path=baseline --mpl-baseline-relative --mpl-generate-summary=html --mpl-results-path='/home/runner/work/bowtie/bowtie/tests/report/' --cov=bowtie bowtie/tests/test.py
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v4
# env:
Expand All @@ -47,4 +47,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.python-version }}-pytest-mpl-report-artifact
path: "/home/runner/work/bowtie/Bowtie/tests/report/"
path: "/home/runner/work/bowtie/bowtie/tests/report/"
Binary file removed Bowtie/__pycache__/Spectra.cpython-39.pyc
Binary file not shown.
Binary file removed Bowtie/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file removed Bowtie/__pycache__/bowtie.cpython-39.pyc
Binary file not shown.
Binary file removed Bowtie/__pycache__/bowtie_util.cpython-39.pyc
Binary file not shown.
Binary file removed Bowtie/__pycache__/plotutil.cpython-39.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions Bowtie/__init__.py → bowtie/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import pandas as pd

from . import bowtie_util as btutil
from . import bowtie
from .Spectra import Spectra
from . import bowtie_calc
from .spectra import Spectra


class Bowtie:
Expand Down Expand Up @@ -67,7 +67,7 @@ def bowtie_analysis(self, channel:str, spectra:Spectra, plot:bool=False,
# The channel effective lower boundary in MeV : {float}
# The channel effective upper boundary in MeV : {float}
# if plot, also returns fig and axes
bowtie_results = bowtie.calculate_bowtie_gf(response_data=response_dict, model_spectra=spectra.power_law_spectra,
bowtie_results = bowtie_calc.calculate_bowtie_gf(response_data=response_dict, model_spectra=spectra.power_law_spectra,
emin=self.energy_min, emax=self.energy_max,
gamma_index_steps=spectra.gamma_steps, use_integral_bowtie=self.integral_bowtie,
sigma=self.sigma, plot=plot, gfactor_confidence_level=geom_factor_confidence,
Expand Down
2 changes: 1 addition & 1 deletion Bowtie/bowtie.py → bowtie/bowtie_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def fold_spectrum_np(*, grid=None, spectrum=None, response=None):
if spectrum is None or response is None:
return 0
if (len(spectrum) == len(response)) and (len(spectrum) == len(grid['midpt'])):
result = np.trapz(np.multiply(spectrum, response), grid['midpt'])
result = np.trapezoid(np.multiply(spectrum, response), grid['midpt'])
return result
else:
return 0
Expand Down
2 changes: 1 addition & 1 deletion Bowtie/bowtie_util.py → bowtie/bowtie_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from matplotlib import pyplot as plt

from . import bowtie
from . import bowtie_calc


def read_npy_vault(vault_name):
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions Bowtie/Spectra.py → bowtie/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__credits__ = ["Christian Palmroos", "Philipp Oleynik"]

from . import bowtie_util
from . import bowtie
from . import bowtie_calc

class Spectra:
"""
Expand Down Expand Up @@ -48,7 +48,7 @@ def produce_power_law_spectra(self, response_df) -> None:
grid = response_matrix[0]["grid"]

# Generates the power law spectra
power_law_spectra = bowtie.generate_exppowlaw_spectra(energy_grid_dict=grid, gamma_pow_min=self.gamma_min,
power_law_spectra = bowtie_calc.generate_exppowlaw_spectra(energy_grid_dict=grid, gamma_pow_min=self.gamma_min,
gamma_pow_max=self.gamma_max, num_steps=self.gamma_steps,
cutoff_energy=self.cutoff_energy)

Expand Down
File renamed without changes.
File renamed without changes
10 changes: 5 additions & 5 deletions Bowtie/tests/test.py → bowtie/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import matplotlib
import os
import pytest
import Bowtie as bow
import bowtie as bow
import numpy as np
import pandas as pd

Expand All @@ -13,14 +13,14 @@
pip install flake8 pytest pytest-doctestplus pytest-cov pytest-mpl
To create/update the baseline images, run the following command from the base package dir:
pytest --mpl-generate-path=tests/baseline Bowtie/tests/test.py
pytest --mpl-generate-path=tests/baseline bowtie/tests/test.py
To run the tests locally, go to the base directory of the repository and run:
pytest -rP --mpl --mpl-baseline-path=baseline --mpl-baseline-relative --mpl-generate-summary=html --cov=Bowtie Bowtie/tests/test.py
pytest -rP --mpl --mpl-baseline-path=baseline --mpl-baseline-relative --mpl-generate-summary=html --cov=bowtie bowtie/tests/test.py
"""


@pytest.mark.mpl_image_compare(remove_text=False, deterministic=True)
@pytest.mark.mpl_image_compare(remove_text=True, deterministic=True)
def test_bowtie():
response_df = pd.read_csv("sixs_side0_electron_responses.csv", index_col="incident_energy")
#
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_bowtie():
column_names = response_df.columns
bow.bowtie_util.save_results(results=all_channels_results, filename=filename, column_names=column_names, save_figures=True)

filecmp.cmp('test.csv', 'Bowtie/tests/test_org.csv')
filecmp.cmp('test.csv', 'bowtie/tests/test_org.csv')

for i in range(1,8):
assert os.path.exists(f'E{i}_bowtie.png')
Expand Down
File renamed without changes.
Binary file added tests/baseline/test_bowtie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 09a9c50

Please sign in to comment.