Skip to content

Commit

Permalink
Pass tests for python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
kavvkon committed Feb 3, 2024
1 parent 8772445 commit 92f7690
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 28 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/pythonpackage.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
max-parallel: 4
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
python-version: [3.7, 3.8, 3.9, 3.10, 3.11]

steps:
- uses: actions/checkout@v2
Expand All @@ -31,9 +31,10 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
pip install pytest pytest-cov coveralls
pytest --cov=.
coveralls
pip install pytest pytest-cov
python -m pytest --cov=. --cov-report xml
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/requirements.txt
@@ -1,4 +1,4 @@
numpy>=1.10
scipy>=1.0
scipy>=1.10
matplotlib>=2.2
pandas>=0.20
pandas>=1.4
11 changes: 6 additions & 5 deletions docs/conf.py
Expand Up @@ -18,7 +18,8 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
#sys.path.insert(0, os.path.abspath('..'))
from enlopy import __version__
autodoc_mock_imports = ['_tkinter']
import matplotlib
matplotlib.use('agg')
Expand Down Expand Up @@ -53,17 +54,17 @@

# General information about the project.
project = u'enlopy'
copyright = u'2017, Kavvadias Konstantinos'
copyright = u'2024, Kavvadias Konstantinos'
author = u'Kavvadias Konstantinos'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'0.1.dev9'
version = __version__
# The full version, including alpha/beta/rc tags.
release = u'0.1.dev9'
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -89,7 +90,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'default'
html_theme = 'pyramid'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
4 changes: 2 additions & 2 deletions enlopy/analysis.py
Expand Up @@ -120,7 +120,7 @@ def get_load_archetypes(Load, k=2, x='hour', y='dayofyear', plot_diagnostics=Fal
return clusters_center_dewhitened


def get_load_stats(Load, per='a'):
def get_load_stats(Load, per='a') -> pd.DataFrame:
"""Find load profile characteristics. Among other it estimates: peak, load factor, base load factor, operating hours,
Arguments:
Expand All @@ -139,7 +139,7 @@ def get_load_stats(Load, per='a'):
print ('Warning: Too many periods ({}) selected'.format(len(g)))
p_dict = {}
for period, load_per in g:
ind = str(period.to_period())
ind = str(period.to_period(freq=per))
p_dict[ind] = {k: v(load_per) for k, v in all_stats_desc.items()} # named tuple instead of dict?
return pd.DataFrame.from_dict(p_dict)

Expand Down
9 changes: 4 additions & 5 deletions enlopy/generate.py
Expand Up @@ -34,7 +34,7 @@ def disag_upsample(Load, disag_profile, to_offset='h'):
orig_freq = Load.index.freqstr
start = Load.index[0]
end = Load.index[-1] + 1 * Load.index.freq #An extra period is needed at the end to match the sum FIXME
df1 = Load.reindex(pd.date_range(start, end, freq=to_offset, closed='left'))
df1 = Load.reindex(pd.date_range(start, end, freq=to_offset, inclusive='left'))

def mult_profile(x, profile):
#Normalizing to keep the sum the same..
Expand Down Expand Up @@ -345,18 +345,17 @@ def add_noise(Load, mode, st, r=0.9, Lmin=0):
else:
raise ValueError('Not available mode')
out[out < Lmin] = Lmin # remove negative elements
return clean_convert(np.squeeze(out), force_timed_index=False) # assume hourly timeseries if no timeindex is passed

return clean_convert(np.squeeze(out), force_timed_index=True, freq='h') # assume hourly timeseries if no timeindex is passed


def gen_analytical_LDC(U, duration=8760, bins=1000):
def gen_analytical_LDC(U, duration=8760,bins=1000):
r"""Generates the Load Duration Curve based on empirical parameters. The following equation is used.
:math:`f(x;P,CF,BF) = \\frac{P-x}{P-BF \\cdot P}^{\\frac{CF-1}{BF-CF}}`
Arguments:
U (tuple): parameter vector [Peak load, capacity factor%, base load%, hours] or dict
Returns:
np.ndarray: a 2D array [x, y] ready for plotting (e.g. plt(*gen_analytical_LDC(U)))
np.ndarray: a 2D array [x, y] ready for plotting (e.g. plt(\*gen_analytical_LDC(U)))
"""
if isinstance(U, dict):
P = U['peak'] # peak load
Expand Down
2 changes: 1 addition & 1 deletion enlopy/plot.py
Expand Up @@ -264,7 +264,7 @@ def flag_operation(v):
figsize=(fig_width, 0.25 * rows), squeeze=False,
frameon=False, gridspec_kw={'hspace': 0.15})

for (item, iseries), iax in zip(df_series.iteritems(), axes.ravel()):
for (item, iseries), iax in zip(df_series.items(), axes.ravel()):
format_axis(iax)
iax.set_ylabel(str(item)[:30], rotation='horizontal',
rotation_mode='anchor',
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
@@ -1,10 +1,10 @@
name: enlopy
dependencies:
- python=3.7
- python=3.9
- numpy>=1.10
- scipy>=1.0
- matplotlib>=2.0
- pandas>=0.20
- pandas>=2.0
- pytest
- pytest-cov
- coverage
14 changes: 9 additions & 5 deletions setup.py
Expand Up @@ -27,9 +27,9 @@ def find_version(*file_paths):
raise RuntimeError("Unable to find version string.")

requirements = ['numpy>=1.10',
'scipy>=0.15',
'matplotlib>=1.5.1',
'pandas>=0.18']
'scipy>=1.10',
'matplotlib>=2.2',
'pandas>=1.4']

setup(
name="enlopy",
Expand Down Expand Up @@ -65,10 +65,14 @@ def find_version(*file_paths):

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
# 'Programming Language :: Python :: 2.7',
# 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',

# distclass=distutils.command.bdist_conda.CondaDistribution,
# conda_buildnum=1,
Expand Down

0 comments on commit 92f7690

Please sign in to comment.