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: move ramstk_load_history to sub-package #993

Merged
merged 26 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
828d045
'Refactored by Sourcery'
Jan 15, 2022
aba689e
Merge branch 'master' into sourcery/master
weibullguy Jan 19, 2022
a767930
Merge branch 'master' into sourcery/master
weibullguy Jan 19, 2022
000557b
Merge branch 'master' into sourcery/master
weibullguy Jan 20, 2022
e1d308c
Merge branch 'master' into sourcery/master
weibullguy Jan 20, 2022
3a24296
Merge branch 'master' into sourcery/master
weibullguy Jan 21, 2022
bfdba06
Merge branch 'master' into sourcery/master
weibullguy Jan 23, 2022
9c4df26
Merge branch 'master' into sourcery/master
weibullguy Jan 27, 2022
23f91a3
Merge branch 'master' into sourcery/master
weibullguy Jan 28, 2022
c05ba0c
Merge branch 'master' into sourcery/master
weibullguy Jan 28, 2022
b9ef6a9
Merge branch 'master' into sourcery/master
weibullguy Jan 29, 2022
ac7eddb
Merge branch 'master' into sourcery/master
weibullguy Jan 29, 2022
8f9f394
Merge branch 'master' into sourcery/master
weibullguy Jan 30, 2022
ef96579
Merge branch master into sourcery/master
weibullguy Feb 2, 2022
f39ef46
Merge branch 'master' into sourcery/master
weibullguy Feb 3, 2022
fd73cb3
Merge branch 'master' into sourcery/master
weibullguy Feb 8, 2022
821be27
Merge branch 'master' into sourcery/master
weibullguy Feb 18, 2022
2f57b34
Merge branch 'master' into sourcery/master
weibullguy Feb 18, 2022
328ea71
Merge 'master' into sourcery/master
weibullguy Feb 21, 2022
8a149d3
Merge branch 'master' into sourcery/master
weibullguy Feb 21, 2022
a85785c
ci: add dummy workflows to allow PR merges
weibullguy Feb 21, 2022
1d4bb4d
refactor: move ramstk_loadhistory to sub-package
weibullguy Feb 22, 2022
8392112
test: update ramstk_loadhistory tests
weibullguy Feb 22, 2022
fe4f8d2
style: update stub file
weibullguy Feb 22, 2022
eb3fce6
style: fix formatting
weibullguy Feb 22, 2022
f66c7c8
style: fix style errors
weibullguy Feb 22, 2022
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
2 changes: 1 addition & 1 deletion .github/trafico.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ labels:
name: "status: closed"
color: "#0E8A16"
description: "Pull Request is complete and integrated or closed for anther reason."
ignore: true
ignore: false
1 change: 1 addition & 0 deletions .github/workflows/do_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
repository_url: https://test.pypi.org/legacy/

- name: Test install from Test PyPI
if: ${{ env.build_ok == 1 }}
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends apt-utils git libgirepository1.0-dev gir1.2-gtk-3.0 python3-gi python3-gi-cairo python3-pytest libenchant1c2a libenchant-dev python3-numpy python3-scipy xauth xvfb
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/dont-static-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This is a dummy workflow that will run when the conditions of the
# do-static-checks workflow aren't met. This allows PRs to be merged when the
# conditions aren't met for a protected branch. See
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks
name: Perform Static Checks on RAMSTK Code Base

on:
push:
paths-ignore:
- "**.py"
pull_request:
paths-ignore:
- "**.py"
types:
- "opened"
- "reopened"
- "synchronize"

jobs:
bandit:
name: Check for Security Vulnerabilities
runs-on: ubuntu-latest
steps:
- run:
echo "No security check required."

format-check:
name: Check Code Formatting
runs-on: ubuntu-latest
steps:
- run:
echo "No files to be formatted."

style-check:
name: Check Code Styling
runs-on: ubuntu-latest
steps:
- run:
echo "No files to be style checked."

type-check:
name: Check Code Type Hinting
runs-on: ubuntu-latest
steps:
- run:
echo "No files to be type checked."

lint-check:
name: Check Code Lint
runs-on: ubuntu-latest
steps:
- run:
echo "No files to be linted."
33 changes: 33 additions & 0 deletions .github/workflows/dont-test-suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is a dummy workflow that will run when the conditions of the
# do-test-suite workflow aren't met. This allows PRs to be merged when the
# conditions aren't met for a protected branch. See
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks
name: Execute RAMSTK Test Suite with Coverage

on:
push:
paths-ignore:
- "**.py"
pull_request:
paths-ignore:
- "**.py"
types:
- "opened"
- "reopened"
- "synchronize"

jobs:
test_suite:
name: Run Test Suite
runs-on: ubuntu-latest
steps:
- run: |
echo "Test suite not required."

upload_coveralls:
name: Upload Results to Coveralls
needs: test_suite
runs-on: ubuntu-latest
steps:
- run: |
echo "No test suite required; no coverage report generated."
13 changes: 0 additions & 13 deletions .github/workflows/on-pr-close.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# This workflow runs when a pull request is closed.
#
# - Job 1:
# - Remove 'status: inprogress' label.
# - Add 'status: closed' label.
# - Job 2:
# - Gets list of PR labels.
# - Get current version from VERSION.
# - Determine next Semantic version.
Expand All @@ -21,16 +18,6 @@ on:
- closed

jobs:
label-pr-closed:
name: Add Closed Label
runs-on: ubuntu-latest
steps:
- name: Add label
uses: andymckay/labeler@master
with:
add-labels: "status: closed"
remove-labels: "status: inprogress"

tag-version:
name: Push Version Tag
runs-on: ubuntu-latest
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/on-pr-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ jobs:
make html
cd ..

- name: Build pdf documentation
run: |
cd docs
make latexpdf LATEXMKOPTS="-silent -f"
cd ..

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v4
Expand All @@ -96,3 +90,9 @@ jobs:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Build pdf documentation
run: |
cd docs
make latexpdf LATEXMKOPTS="-silent -f"
cd ..
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ disable = [
'fixme',
'anomalous-unicode-escape-in-string',
'import-error',
'no-member'
'no-member',
'no-else-return'
]

[tool.pylint.reports]
Expand Down
11 changes: 5 additions & 6 deletions src/ramstk/analyses/allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,8 @@ def get_allocation_goal(**attributes: Dict[str, Any]) -> Dict[str, Any]:
:raise: KeyError if the passed attributes dict doesn't contain the
allocation_method_id, hazard_rate_goal, and/or reliability_goal key.
"""
if attributes["allocation_method_id"] in [2, 4]: # ARINC or FOO.
_goal = attributes["hazard_rate_goal"]
else:
_goal = attributes["reliability_goal"]

return _goal
return (
attributes["hazard_rate_goal"]
if attributes["allocation_method_id"] in [2, 4]
else attributes["reliability_goal"]
)
4 changes: 1 addition & 3 deletions src/ramstk/analyses/criticality.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ def calculate_rpn(sod):
if not 0 < sod["rpn_detection"] < 11:
raise OutOfRangeError(("RPN detection is outside the range [1, 10]."))

_rpn = (
return (
int(sod["rpn_severity"])
* int(sod["rpn_occurrence"])
* int(sod["rpn_detection"])
)

return _rpn


def calculate_mode_hazard_rate(item_hr, mode_ratio):
"""Calculate the failure mode hazard rate.
Expand Down
7 changes: 3 additions & 4 deletions src/ramstk/analyses/fha.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,9 @@ def set_user_defined_functions(
for _idx in [6, 7, 8, 9, 10]:
try:
_key = list(fha.keys())[_idx]
if str(functions[_idx - 6]) == "":
fha[_key] = "0.0"
else:
fha[_key] = str(functions[_idx - 6])
fha[_key] = (
"0.0" if not str(functions[_idx - 6]) else str(functions[_idx - 6])
)
except IndexError:
fha[_key] = "0.0"

Expand Down
59 changes: 27 additions & 32 deletions src/ramstk/analyses/milhdbk217f/milhdbk217f.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,14 @@ def _get_environment_factor(
10: {1: crystal.PI_E, 2: efilter.PI_E, 3: fuse.PI_E, 4: lamp.PI_E},
}

if category_id == 8 and subcategory_id in [1, 2]:
_pi_e = _pi_e_lists[category_id][subcategory_id][quality_id][
if category_id == 8 and subcategory_id in {1, 2}:
return _pi_e_lists[category_id][subcategory_id][quality_id][
environment_active_id - 1
]
elif category_id in [2, 3, 5, 7, 9, 10] or (
category_id == 8 and subcategory_id not in [1, 2]
):
_pi_e = _pi_e_lists[category_id][subcategory_id][environment_active_id - 1]
elif category_id in {2, 3, 5, 7, 9, 10, 8}:
return _pi_e_lists[category_id][subcategory_id][environment_active_id - 1]
else:
_pi_e = _pi_e_lists[category_id][environment_active_id - 1]

return _pi_e
return _pi_e_lists[category_id][environment_active_id - 1]


def _get_part_count_quality_factor(
Expand Down Expand Up @@ -276,18 +272,17 @@ def _get_part_count_quality_factor(
10: {1: crystal.PART_COUNT_PI_Q, 2: efilter.PI_Q},
}

if category_id in [6, 7, 9]:
_pi_q = _pi_q_lists[category_id][subcategory_id][quality_id - 1]
elif category_id == 10 and subcategory_id in [1, 2]:
_pi_q = _pi_q_lists[category_id][subcategory_id][quality_id - 1]
elif category_id == 10 and subcategory_id in [3, 4]:
_pi_q = 1.0
if category_id in {6, 7, 9}:
return _pi_q_lists[category_id][subcategory_id][quality_id - 1]
elif category_id == 10 and subcategory_id in {1, 2}:
return _pi_q_lists[category_id][subcategory_id][quality_id - 1]
elif category_id == 10 and subcategory_id in {3, 4}:
return 1.0
else:
_pi_q = _pi_q_lists[category_id][quality_id - 1]

return _pi_q
return _pi_q_lists[category_id][quality_id - 1]


# pylint: disable=too-many-return-statements
def _get_part_stress_quality_factor(
category_id: int, subcategory_id: int, quality_id: int
) -> float:
Expand Down Expand Up @@ -315,20 +310,20 @@ def _get_part_stress_quality_factor(
}

if category_id == 1:
_pi_q = _pi_q_lists[category_id][quality_id - 1]
elif (category_id == 8 and subcategory_id in [4, 5]) or (
category_id == 7 and subcategory_id == 5
return _pi_q_lists[category_id][quality_id - 1]
elif (
category_id == 8
and subcategory_id in {4, 5}
or (category_id == 7 and subcategory_id == 5)
):
_pi_q = _pi_q_lists[category_id][subcategory_id][quality_id - 1]
elif category_id == 7 and subcategory_id != 5:
_pi_q = 0.0
elif category_id == 8 and subcategory_id not in [4, 5]:
_pi_q = 0.0
return _pi_q_lists[category_id][subcategory_id][quality_id - 1]
elif category_id == 7:
return 0.0
elif category_id == 8:
return 0.0
elif category_id == 9 and subcategory_id == 1:
_pi_q = 0.0
elif category_id == 10 and subcategory_id in [3, 4]:
_pi_q = 0.0
return 0.0
elif category_id == 10 and subcategory_id in {3, 4}:
return 0.0
else:
_pi_q = _pi_q_lists[category_id][subcategory_id][quality_id - 1]

return _pi_q
return _pi_q_lists[category_id][subcategory_id][quality_id - 1]
37 changes: 15 additions & 22 deletions src/ramstk/analyses/milhdbk217f/models/capacitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,7 @@ def calculate_capacitance_factor(subcategory_id: int, capacitance: float) -> flo
}
_f0 = _dic_factors[subcategory_id][0]
_f1 = _dic_factors[subcategory_id][1]
_pi_cv = _f0 * capacitance ** _f1

return _pi_cv
return _f0 * capacitance ** _f1


def calculate_part_count(**attributes: Dict[str, Any]) -> float:
Expand Down Expand Up @@ -549,14 +547,12 @@ def calculate_part_stress_lambda_b(
_f2 = _dic_factors[subcategory_id][2]
_f3 = _dic_factors[subcategory_id][3]
_f4 = _dic_factors[subcategory_id][4]
_lambda_b = (
return (
_f0
* ((voltage_ratio / _f1) ** _f2 + 1.0)
* exp(_f3 * ((temperature_active + 273.0) / _ref_temp) ** _f4)
)

return _lambda_b


def calculate_series_resistance_factor(
resistance: float, voltage_dc_operating: float, voltage_ac_operating: float
Expand All @@ -576,19 +572,17 @@ def calculate_series_resistance_factor(
_ckt_resistance = resistance / (voltage_dc_operating + voltage_ac_operating)

if 0 < _ckt_resistance <= 0.1:
_pi_sr = 0.33
return 0.33
elif 0.1 < _ckt_resistance <= 0.2:
_pi_sr = 0.27
return 0.27
elif 0.2 < _ckt_resistance <= 0.4:
_pi_sr = 0.2
return 0.2
elif 0.4 < _ckt_resistance <= 0.6:
_pi_sr = 0.13
return 0.13
elif 0.6 < _ckt_resistance <= 0.8:
_pi_sr = 0.1
return 0.1
else:
_pi_sr = 0.066

return _pi_sr
return 0.066


def get_configuration_factor(configuration_id: int) -> float:
Expand Down Expand Up @@ -696,13 +690,12 @@ def get_part_count_lambda_b(
:rtype: float
:raise: KeyError if passed an unknown subcategory ID or specification ID.
"""
if subcategory_id == 1:
_base_hr = PART_COUNT_LAMBDA_B[subcategory_id][ # type: ignore
specification_id
][environment_active_id - 1]
else:
_base_hr = PART_COUNT_LAMBDA_B[subcategory_id][ # type: ignore
return (
PART_COUNT_LAMBDA_B[subcategory_id][specification_id][ # type: ignore
environment_active_id - 1
]

return _base_hr
if subcategory_id == 1
else PART_COUNT_LAMBDA_B[subcategory_id][ # type: ignore
environment_active_id - 1
]
)
Loading