Skip to content

Commit

Permalink
Merge pull request #131 from pail23/master
Browse files Browse the repository at this point in the history
Upgrade to python 3.11
  • Loading branch information
davidusb-geek authored Dec 16, 2023
2 parents 52064b0 + 1719b54 commit 53dc763
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.8-buster
FROM mcr.microsoft.com/devcontainers/python:0-3.11

COPY .devcontainer/setup.sh requirements.txt requirements_webserver.txt ./
RUN ./setup.sh
4 changes: 2 additions & 2 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
- name: Special dependencies for macos
run: |
brew install hdf5
pip3 install numpy==1.22.2
pip3 install tables==3.7.0
pip3 install numpy==1.26.0
pip3 install tables==3.9.1
if: ${{ matrix.os == 'macos-latest' }}

- name: Install dependencies
Expand Down
8 changes: 4 additions & 4 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
wheel
numpy==1.22.2
pandas==1.4.1
scipy<1.9.0
numpy==1.26.0
pandas==2.0.3
scipy==1.11.3
pvlib>=0.10.1
protobuf>=3.0.0
pytz>=2021.1
requests>=2.25.1
beautifulsoup4>=4.9.3
pulp>=2.4
pyyaml>=5.4.1
tables==3.7.0
tables==3.9.1
skforecast==0.11.0
markupsafe==2.1.3
Jinja2<3.2
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
# These are the assumed default build requirements from pip:
# https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
requires = ["setuptools==40.8.0", "wheel"]
requires = ["setuptools>=62.0.0", "wheel"]
build-backend = "setuptools.build_meta"
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
wheel
numpy==1.22.2
pandas==1.4.1
scipy<1.9.0
numpy==1.26.0
pandas==2.0.3
scipy==1.11.3
pvlib>=0.10.1
protobuf>=3.0.0
pytz>=2021.1
requests>=2.25.1
beautifulsoup4>=4.9.3
pulp>=2.4
pyyaml>=5.4.1
tables==3.7.0
skforecast==0.11.0
tables==3.9.1
skforecast==0.11.0
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@
keywords='energy, management, optimization, hass', # Optional
package_dir={'': 'src'}, # Optional
packages=find_packages(where='src'), # Required
python_requires='>=3.9, <=3.10',
python_requires='>=3.9, <3.12',
install_requires=[
'wheel',
'numpy==1.22.2',
'scipy<1.9.0',
'pandas==1.4.1',
'numpy==1.26',
'scipy==1.11.3',
'pandas==2.0.3',
'pvlib>=0.10.1',
'protobuf>=3.0.0',
'pytz>=2021.1',
'requests>=2.25.1',
'beautifulsoup4>=4.9.3',
'pulp>=2.4',
'pyyaml>=5.4.1',
'tables==3.7.0',
'tables==3.9.1',
'skforecast==0.11.0',
], # Optional
entry_points={ # Optional
Expand Down
6 changes: 3 additions & 3 deletions src/emhass/retrieve_hass.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ def get_data(self, days_list: pd.date_range, var_list: list, minimal_response: O
self.logger.error("Retrieved empty Dataframe, check that correct day or variable names are passed")
self.logger.error("Either the names of the passed variables are not correct or days_to_retrieve is larger than the recorded history of your sensor (check your recorder settings)")
if i == 0: # Defining the DataFrame container
from_date = pd.to_datetime(df_raw['last_changed']).min()
to_date = pd.to_datetime(df_raw['last_changed']).max()
from_date = pd.to_datetime(df_raw['last_changed'], format="ISO8601").min()
to_date = pd.to_datetime(df_raw['last_changed'], format="ISO8601").max()
ts = pd.to_datetime(pd.date_range(start=from_date, end=to_date, freq=self.freq),
format='%Y-%d-%m %H:%M').round(self.freq)
df_day = pd.DataFrame(index = ts)
# Caution with undefined string data: unknown, unavailable, etc.
df_tp = df_raw.copy()[['state']].replace(
['unknown', 'unavailable', ''], np.nan).astype(float).rename(columns={'state': var})
# Setting index, resampling and concatenation
df_tp.set_index(pd.to_datetime(df_raw['last_changed']), inplace=True)
df_tp.set_index(pd.to_datetime(df_raw['last_changed'], format="ISO8601"), inplace=True)
df_tp = df_tp.resample(self.freq).mean()
df_day = pd.concat([df_day, df_tp], axis=1)

Expand Down
3 changes: 2 additions & 1 deletion tests/test_retrieve_hass.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import datetime
import unittest
import requests_mock
import numpy as np, pandas as pd
Expand Down Expand Up @@ -100,7 +101,7 @@ def test_get_data_mock(self):
self.assertIsInstance(self.rh.df_final.index.dtype, pd.core.dtypes.dtypes.DatetimeTZDtype)
self.assertEqual(len(self.rh.df_final.columns), len(var_list))
self.assertEqual(self.rh.df_final.index.freq, self.retrieve_hass_conf['freq'])
self.assertEqual(self.rh.df_final.index.tz, pytz.UTC)
self.assertEqual(self.rh.df_final.index.tz, datetime.timezone.utc)

def test_prepare_data(self):
self.assertIsInstance(self.rh.df_final, type(pd.DataFrame()))
Expand Down

0 comments on commit 53dc763

Please sign in to comment.