Skip to content

Commit 812f242

Browse files
authored
Merge pull request #1 from BitBloomTech/use-tables
Replace h5py dependency with tables
2 parents 1e6f870 + 35923e3 commit 812f242

4 files changed

Lines changed: 60 additions & 10 deletions

File tree

azure-pipelines.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
trigger:
2+
branches:
3+
include:
4+
- main
5+
- refs/tags/*
6+
7+
pool:
8+
vmImage: ubuntu-latest
9+
10+
stages:
11+
- stage: Build
12+
jobs:
13+
- job: Python314Build
14+
timeoutInMinutes: 120
15+
container: python:3.14
16+
steps:
17+
- checkout: self
18+
fetchDepth: 0
19+
fetchTags: true
20+
- script: python -m venv $(Build.SourcesDirectory)/.venv
21+
displayName: "Creating virtual environment"
22+
- task: PipAuthenticate@1
23+
inputs:
24+
artifactFeeds: 'bitbloom-artifacts'
25+
onlyAddExtraIndex: True
26+
- script: |
27+
source $(Build.SourcesDirectory)/.venv/bin/activate
28+
pip install .[test,build]
29+
displayName: "Installing pvlib"
30+
- script: |
31+
source $(Build.SourcesDirectory)/.venv/bin/activate
32+
python -m pytest tests
33+
displayName: "Running tests with pytest"
34+
- task: TwineAuthenticate@1
35+
inputs:
36+
artifactFeed: "bitbloom-artifacts"
37+
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
38+
- script: |
39+
source $(Build.SourcesDirectory)/.venv/bin/activate
40+
TAG="${BUILD_SOURCEBRANCH#refs/tags/}"
41+
TAG="${TAG#v}"
42+
export SETUPTOOLS_SCM_PRETEND_VERSION="$TAG"
43+
echo "Using package version: $SETUPTOOLS_SCM_PRETEND_VERSION"
44+
python -m pip install build
45+
python -m build --sdist --outdir dist
46+
python -m twine upload -r "bitbloom-artifacts" --config-file $(PYPIRC_PATH) dist/*.tar.gz
47+
displayName: "Building and publishing sdist package"
48+
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))

pvlib/clearsky.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import numpy as np
1111
import pandas as pd
1212
from scipy.linalg import hankel
13-
import h5py
13+
import tables
1414

1515
from pvlib import atmosphere, tools
1616
from pvlib.tools import _degrees_to_index
@@ -206,8 +206,8 @@ def lookup_linke_turbidity(time, latitude, longitude, filepath=None,
206206
latitude_index = _degrees_to_index(latitude, coordinate='latitude')
207207
longitude_index = _degrees_to_index(longitude, coordinate='longitude')
208208

209-
with h5py.File(filepath, 'r') as lt_h5_file:
210-
lts = lt_h5_file['LinkeTurbidity'][latitude_index, longitude_index]
209+
with tables.open_file(filepath, mode='r') as lt_h5_file:
210+
lts = lt_h5_file.root.LinkeTurbidity[latitude_index, longitude_index]
211211

212212
if interp_turbidity:
213213
linke_turbidity = _interpolate_turbidity(lts, time)

pvlib/location.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import pandas as pd
1212
import pytz
13-
import h5py
13+
import tables
1414

1515
from pvlib import solarposition, clearsky, atmosphere, irradiance
1616
from pvlib.tools import _degrees_to_index
@@ -494,8 +494,8 @@ def lookup_altitude(latitude, longitude):
494494
latitude_index = _degrees_to_index(latitude, coordinate='latitude')
495495
longitude_index = _degrees_to_index(longitude, coordinate='longitude')
496496

497-
with h5py.File(filepath, 'r') as alt_h5_file:
498-
alt = alt_h5_file['Altitude'][latitude_index, longitude_index]
497+
with tables.open_file(filepath, mode='r') as alt_h5_file:
498+
alt = alt_h5_file.root.Altitude[latitude_index, longitude_index]
499499

500500
# 255 is a special value that means nodata. Fallback to 0 if nodata.
501501
if alt == 255:

pyproject.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools>=70.1", "setuptools_scm>=6.2"]
2+
requires = ["setuptools>=70.1", "setuptools_scm>=6.2", "twine"]
33
build-backend = "setuptools.build_meta"
44

55

@@ -16,10 +16,9 @@ dependencies = [
1616
'pytz',
1717
'requests',
1818
'scipy >= 1.7.2',
19-
'h5py',
19+
'tables',
2020
'tzdata', # ensure all timezones are available in all installs for consistency GH#2795
2121
]
22-
license = "BSD-3-Clause"
2322
classifiers = [
2423
'Development Status :: 4 - Beta',
2524
'Operating System :: OS Independent',
@@ -78,7 +77,10 @@ test = [
7877
'pytest-remotedata',
7978
'packaging',
8079
]
81-
all = ["pvlib[test,optional,doc]"]
80+
build = [
81+
"twine"
82+
]
83+
all = ["pvlib[test,optional,doc,build]"]
8284

8385
[project.urls]
8486
"Bug Tracker" = "https://github.com/pvlib/pvlib-python/issues"

0 commit comments

Comments
 (0)