diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 2bb4382..75f5d88 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -7,7 +7,6 @@ on: push: branches: - main - - feature/grid # Allow the workflow to be manually triggered from the Actions tab. workflow_dispatch: @@ -142,7 +141,9 @@ jobs: runs-on: ubuntu-latest # Require a tag push to publish a release distribution. - if: startsWith(github.ref, 'refs/tags/') +# if: > +# startsWith(github.ref, 'refs/tags/') +# || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != '') # The distribution will only be published if the tests have passed. needs: @@ -173,7 +174,9 @@ jobs: runs-on: ubuntu-latest # GitHub releases are only uploaded for release (tagged) distributions. - needs: [deploy-release] + needs: + - deploy-release + - build permissions: contents: write # IMPORTANT: mandatory for making GitHub Releases diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml new file mode 100644 index 0000000..e467d21 --- /dev/null +++ b/.github/workflows/update-version.yml @@ -0,0 +1,45 @@ +name: update-version + +# The deployment workflow should only run when changes are merged into the `main` branch. +# Since a branch protection rule prevents directly pushing to `main` this workflow will +# only run on a successful merge request. +on: + # Allow the workflow to be manually triggered from the Actions tab. + workflow_dispatch: + inputs: + tag_name: + description: 'If you want to update the version and release, type an existing or new version tag (eg. 1.2.0)' + required: false + default: '' + +jobs: + + update-version: + name: Update Version + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != '' }} + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Update version in pyproject.toml + run: | + sed -i "s/^version = .*/version = \"${{ github.event.inputs.tag_name }}\"/" pyproject.toml + + - name: Update version in setup.cfg + run: | + sed -i "s/^version = .*/version = ${{ github.event.inputs.tag_name }}/" setup.cfg + + - name: Commit and push version update + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add pyproject.toml setup.cfg + git commit -m "chore: update version to ${{ github.event.inputs.tag_name }}" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/src/hecdss/gridded_data.py b/src/hecdss/gridded_data.py index e6a7af8..f75b82e 100644 --- a/src/hecdss/gridded_data.py +++ b/src/hecdss/gridded_data.py @@ -114,12 +114,12 @@ def range_limit_table(self, minval, maxval, range_, bins, datasize, data): self.rangeLimitTable[i] = minval + step * i self.rangeLimitTable[bins - 1] = maxval - # Exceedance - for idx in range(datasize): - for jdx in range(bins): - if data[idx] >= self.rangeLimitTable[jdx]: - self.numberEqualOrExceedingRangeLimit[jdx] += 1 + sorted_data = np.sort(data) + n = len(sorted_data) + for jdx in range(bins): + idx = np.searchsorted(sorted_data, self.rangeLimitTable[jdx], side="left") + self.numberEqualOrExceedingRangeLimit[jdx] = n - idx def update_grid_info(self): """ @@ -135,7 +135,7 @@ def update_grid_info(self): self.data = np.nan_to_num(self.data, nan=NULL_INT) self.numberOfRanges = math.floor(1 + 3.322 * math.log10(n) + 1) - flat_data = self.data.flatten() + flat_data = self.data.ravel() self.range_limit_table(self.minDataValue, self.maxDataValue, bin_range, self.numberOfRanges, n, flat_data) @staticmethod