Skip to content

Commit 2903a42

Browse files
committed
gridded_data speed up and test publish
1 parent bd9f227 commit 2903a42

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deployment
1+
name: Test Deployment
22

33
# The deployment workflow should only run when changes are merged into the `main` branch.
44
# Since a branch protection rule prevents directly pushing to `main` this workflow will
@@ -11,6 +11,11 @@ on:
1111

1212
# Allow the workflow to be manually triggered from the Actions tab.
1313
workflow_dispatch:
14+
inputs:
15+
tag_name:
16+
description: 'If you want to run a release, type an existing or new tag (eg. v1.2.0)'
17+
required: false
18+
default: ''
1419

1520
jobs:
1621
# Build and test the distribution before deploying to the various platforms. This allows
@@ -142,7 +147,9 @@ jobs:
142147
runs-on: ubuntu-latest
143148

144149
# Require a tag push to publish a release distribution.
145-
if: startsWith(github.ref, 'refs/tags/')
150+
if: >
151+
startsWith(github.ref, 'refs/tags/')
152+
|| (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != '')
146153
147154
# The distribution will only be published if the tests have passed.
148155
needs:

src/hecdss/gridded_data.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# import pandas as pd
22
import numpy as np
33
import math
4+
import time
45

56
NULL_INT = -3.4028234663852886e+38
67

@@ -114,12 +115,12 @@ def range_limit_table(self, minval, maxval, range_, bins, datasize, data):
114115
self.rangeLimitTable[i] = minval + step * i
115116

116117
self.rangeLimitTable[bins - 1] = maxval
117-
118118
# 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
119+
sorted_data = np.sort(data)
120+
n = len(sorted_data)
121+
for jdx in range(bins):
122+
idx = np.searchsorted(sorted_data, self.rangeLimitTable[jdx], side="left")
123+
self.numberEqualOrExceedingRangeLimit[jdx] = n - idx
123124

124125
def update_grid_info(self):
125126
"""
@@ -135,7 +136,7 @@ def update_grid_info(self):
135136

136137
self.data = np.nan_to_num(self.data, nan=NULL_INT)
137138
self.numberOfRanges = math.floor(1 + 3.322 * math.log10(n) + 1)
138-
flat_data = self.data.flatten()
139+
flat_data = self.data.ravel()
139140
self.range_limit_table(self.minDataValue, self.maxDataValue, bin_range, self.numberOfRanges, n, flat_data)
140141

141142
@staticmethod

0 commit comments

Comments
 (0)