Skip to content

Commit eb97f25

Browse files
authored
Gridded data publish (#96)
* gridded_data speed up and test publish * update release
1 parent fc91e14 commit eb97f25

File tree

3 files changed

+57
-9
lines changed

3 files changed

+57
-9
lines changed

.github/workflows/publish-to-test-pypi.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
push:
88
branches:
99
- main
10-
- feature/grid
1110

1211
# Allow the workflow to be manually triggered from the Actions tab.
1312
workflow_dispatch:
@@ -142,7 +141,9 @@ jobs:
142141
runs-on: ubuntu-latest
143142

144143
# Require a tag push to publish a release distribution.
145-
if: startsWith(github.ref, 'refs/tags/')
144+
# if: >
145+
# startsWith(github.ref, 'refs/tags/')
146+
# || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != '')
146147

147148
# The distribution will only be published if the tests have passed.
148149
needs:
@@ -173,7 +174,9 @@ jobs:
173174
runs-on: ubuntu-latest
174175

175176
# GitHub releases are only uploaded for release (tagged) distributions.
176-
needs: [deploy-release]
177+
needs:
178+
- deploy-release
179+
- build
177180

178181
permissions:
179182
contents: write # IMPORTANT: mandatory for making GitHub Releases
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: update-version
2+
3+
# The deployment workflow should only run when changes are merged into the `main` branch.
4+
# Since a branch protection rule prevents directly pushing to `main` this workflow will
5+
# only run on a successful merge request.
6+
on:
7+
# Allow the workflow to be manually triggered from the Actions tab.
8+
workflow_dispatch:
9+
inputs:
10+
tag_name:
11+
description: 'If you want to update the version and release, type an existing or new version tag (eg. 1.2.0)'
12+
required: false
13+
default: ''
14+
15+
jobs:
16+
17+
update-version:
18+
name: Update Version
19+
runs-on: ubuntu-latest
20+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != '' }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.x'
28+
29+
- name: Update version in pyproject.toml
30+
run: |
31+
sed -i "s/^version = .*/version = \"${{ github.event.inputs.tag_name }}\"/" pyproject.toml
32+
33+
- name: Update version in setup.cfg
34+
run: |
35+
sed -i "s/^version = .*/version = ${{ github.event.inputs.tag_name }}/" setup.cfg
36+
37+
- name: Commit and push version update
38+
run: |
39+
git config user.name "github-actions[bot]"
40+
git config user.email "github-actions[bot]@users.noreply.github.com"
41+
git add pyproject.toml setup.cfg
42+
git commit -m "chore: update version to ${{ github.event.inputs.tag_name }}"
43+
git push
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

src/hecdss/gridded_data.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ def range_limit_table(self, minval, maxval, range_, bins, datasize, data):
114114
self.rangeLimitTable[i] = minval + step * i
115115

116116
self.rangeLimitTable[bins - 1] = maxval
117-
118117
# Exceedance
119-
for idx in range(datasize):
120-
for jdx in range(bins):
121-
if data[idx] >= self.rangeLimitTable[jdx]:
122-
self.numberEqualOrExceedingRangeLimit[jdx] += 1
118+
sorted_data = np.sort(data)
119+
n = len(sorted_data)
120+
for jdx in range(bins):
121+
idx = np.searchsorted(sorted_data, self.rangeLimitTable[jdx], side="left")
122+
self.numberEqualOrExceedingRangeLimit[jdx] = n - idx
123123

124124
def update_grid_info(self):
125125
"""
@@ -135,7 +135,7 @@ def update_grid_info(self):
135135

136136
self.data = np.nan_to_num(self.data, nan=NULL_INT)
137137
self.numberOfRanges = math.floor(1 + 3.322 * math.log10(n) + 1)
138-
flat_data = self.data.flatten()
138+
flat_data = self.data.ravel()
139139
self.range_limit_table(self.minDataValue, self.maxDataValue, bin_range, self.numberOfRanges, n, flat_data)
140140

141141
@staticmethod

0 commit comments

Comments
 (0)