Skip to content

Replace h5py dependency with tables #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
trigger:
branches:
include:
- main
- refs/tags/*

pool:
vmImage: ubuntu-latest

stages:
- stage: Build
jobs:
- job: Python310Build
timeoutInMinutes: 120
container: python:3.10.11
steps:
- script: python -m venv $(Build.SourcesDirectory)/.venv
displayName: "Creating virtual environment"
- task: PipAuthenticate@1
inputs:
artifactFeeds: 'bitbloom-artifacts'
onlyAddExtraIndex: True
- script: |
source $(Build.SourcesDirectory)/.venv/bin/activate
pip install .[test,build]
displayName: "Installing pvlib"
- script: |
source $(Build.SourcesDirectory)/.venv/bin/activate
python -m pytest tests
displayName: "Running tests with pytest"
- task: TwineAuthenticate@1
inputs:
artifactFeed: "bitbloom-artifacts"
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
- script: |
source $(Build.SourcesDirectory)/.venv/bin/activate
python setup.py sdist
python -m twine upload -r "bitbloom-artifacts" --config-file $(PYPIRC_PATH) dist/*.tar.gz
displayName: "Building and publishing sdist package"
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
6 changes: 3 additions & 3 deletions pvlib/clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np
import pandas as pd
from scipy.linalg import hankel
import h5py
import tables

from pvlib import atmosphere, tools
from pvlib.tools import _degrees_to_index
Expand Down Expand Up @@ -201,8 +201,8 @@ def lookup_linke_turbidity(time, latitude, longitude, filepath=None,
latitude_index = _degrees_to_index(latitude, coordinate='latitude')
longitude_index = _degrees_to_index(longitude, coordinate='longitude')

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

if interp_turbidity:
linke_turbidity = _interpolate_turbidity(lts, time)
Expand Down
6 changes: 3 additions & 3 deletions pvlib/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import pandas as pd
import pytz
import h5py
import tables

from pvlib import solarposition, clearsky, atmosphere, irradiance
from pvlib.tools import _degrees_to_index
Expand Down Expand Up @@ -481,8 +481,8 @@ def lookup_altitude(latitude, longitude):
latitude_index = _degrees_to_index(latitude, coordinate='latitude')
longitude_index = _degrees_to_index(longitude, coordinate='longitude')

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

# 255 is a special value that means nodata. Fallback to 0 if nodata.
if alt == 255:
Expand Down
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=70.1", "setuptools_scm>=6.2"]
requires = ["setuptools>=70.1", "setuptools_scm>=6.2", "twine"]
build-backend = "setuptools.build_meta"


Expand All @@ -16,9 +16,8 @@ dependencies = [
'pytz',
'requests',
'scipy >= 1.6.0',
'h5py',
'tables',
]
license = "BSD-3-Clause"
classifiers = [
'Development Status :: 4 - Beta',
'Operating System :: OS Independent',
Expand Down Expand Up @@ -77,7 +76,10 @@ test = [
'pytest-remotedata',
'packaging',
]
all = ["pvlib[test,optional,doc]"]
build = [
"twine"
]
all = ["pvlib[test,optional,doc,build]"]

[project.urls]
"Bug Tracker" = "https://github.com/pvlib/pvlib-python/issues"
Expand Down
Loading