Skip to content

Commit

Permalink
Merge pull request #134 from FlorianPfaff/megalinter-v7.3.0
Browse files Browse the repository at this point in the history
Upped mega linter to v7.3.0
  • Loading branch information
FlorianPfaff authored Aug 12, 2023
2 parents 89b9c98 + c41d767 commit ead0324
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 23 deletions.
30 changes: 13 additions & 17 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ jobs:
cd ..
mv SHTOOLS/dist/*.whl ./alpine-wheels/
rm -rf SHTOOLS
rm -rf CMakeFiles
elif ! pip download --only-binary=:all: --no-deps "$package" -d ./alpine-wheels > /dev/null 2>&1; then
echo "No compatible wheel for $package found, building..."
pip wheel --wheel-dir=./alpine-wheels "$package"
Expand All @@ -128,25 +127,22 @@ jobs:
- name: List available wheels
run: ls -l ./alpine-wheels

- name: Clean up temporary files (in case they are generated)
run: rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake Makefile

# MegaLinter
- name: MegaLinter
id: ml
# You can override MegaLinter flavor used to have faster performances
# More info at https://megalinter.io/flavors/
uses: oxsecurity/megalinter/flavors/python@v7.1.0
# More info at https://megalinter.io/latest/configuration/#shared-variables
uses: oxsecurity/megalinter/flavors/python@v7.3.0
env:
# All available variables are described in documentation
# https://megalinter.io/configuration/
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://megalinter.io/latest/configuration/#shared-variables
# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
# DISABLE: COPYPASTE,SPELL # Uncomment to disable copy-paste and spell checks
#with:
# args: -v ${{ github.workspace }}/cache-directory:/cache-directory

#- name: List cache-directory contents
# if: ${{ success() }} || ${{ failure() }}
# run: ls -la ${{ github.workspace }}/cache-directory
VALIDATE_ALL_CODEBASE: true # ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EMAIL_REPORTER_SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}

# Upload MegaLinter artifacts
- name: Archive production artifacts
Expand All @@ -161,25 +157,25 @@ jobs:
# Create pull request if applicable (for now works only on PR from same repository, not from forks)
- name: Create Pull Request with applied fixes
id: cpr
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
commit-message: "[MegaLinter] Apply linters automatic fixes"
title: "[MegaLinter] Apply linters automatic fixes"
labels: bot
- name: Create PR output
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
# Push new commit if applicable (for now works only on PR from same repository, not from forks)
- name: Prepare commit
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
run: sudo chown -Rc $UID .git/
- name: Commit and push applied linter fixes
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update-requirements.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Update requirements.txt

permissions:
Expand Down
1 change: 1 addition & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ DISABLE_LINTERS:
- REPOSITORY_TRIVY # Reenable as soon as (if?) https://avd.aquasec.com/nvd/2021/cve-2021-29063/ confirms that 1.3.0 is no longer a risk
- JSON_JSONLINT # Disable because there is only .devcontainer.json, for which it throws an unwanted warning
- MAKEFILE_CHECKMAKE # Not using a Makefile
- REPOSITORY_GRYPE # Currently, a false alarm is raised
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Please refer to the test cases for usage examples.

## Credits

- Florian Pfaff ([email protected])
- Florian Pfaff (<[email protected]>)

pyRecEst borrows its structure from libDirectional and follows its code closely for many classes. libDirectional, a project to which I contributed extensively, is [available on GitHub](https://github.com/libDirectional).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from .custom_hypertoroidal_distribution import CustomHypertoroidalDistribution
from .abstract_toroidal_distribution import AbstractToroidalDistribution
from .custom_hypertoroidal_distribution import CustomHypertoroidalDistribution


class CustomToroidalDistribution(CustomHypertoroidalDistribution, AbstractToroidalDistribution):
class CustomToroidalDistribution(
CustomHypertoroidalDistribution, AbstractToroidalDistribution
):
def __init__(self, f):
AbstractToroidalDistribution.__init__(self)
CustomHypertoroidalDistribution.__init__(self, f, 2)
CustomHypertoroidalDistribution.__init__(self, f, 2)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ def __init__(self, mu, kappa, lambda_):
@property
def norm_const(self):
def s(m):
return comb(2 * m, m) * (self.lambda_ ** 2 / 4 / self.kappa[0] / self.kappa[1]) ** m * iv(m, self.kappa[0]) * iv(m, self.kappa[1])
return (
comb(2 * m, m)
* (self.lambda_**2 / 4 / self.kappa[0] / self.kappa[1]) ** m
* iv(m, self.kappa[0])
* iv(m, self.kappa[1])
)

Cinv = 4 * np.pi**2 * np.sum([s(m) for m in range(11)])
return Cinv

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def convolve(self, other):
return GaussianDistribution(new_mu, new_C, check_validity=False)

def marginalize_out(self, dimensions):
if type(dimensions) is int: # Make it iterable if single integer
if isinstance(dimensions, int): # Make it iterable if single integer
dimensions = [dimensions]
assert all(dim <= self.dim for dim in dimensions)
remaining_dims = [i for i in range(self.dim) if i not in dimensions]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ def test_reweigh(self):
# Define functions for testing
def f1(x):
return np.sum(x, axis=-1) == 3

def f2(x):
return 2 * np.ones(x.shape[0])

def f3(x):
return x[:, 0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def laplace(x):

def pdftemp(x):
return sum(laplace(z) for z in x + 2 * np.pi * np.arange(-20, 21))

for x in [0, 1, 2, 3, 4]:
np.testing.assert_allclose(self.wl.pdf(x), pdftemp(x), rtol=1e-10)

Expand Down

0 comments on commit ead0324

Please sign in to comment.