diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 69f41cf..4fd206a 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -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 @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/requirements.txt b/.github/workflows/requirements.txt index e32a8a4..01c2c2a 100644 --- a/.github/workflows/requirements.txt +++ b/.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 diff --git a/docs/conf.py b/docs/conf.py index 3f62b59..c3075df 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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') @@ -53,7 +54,7 @@ # 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 @@ -61,9 +62,9 @@ # 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. @@ -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 diff --git a/enlopy/analysis.py b/enlopy/analysis.py index 437d09f..dc635ee 100644 --- a/enlopy/analysis.py +++ b/enlopy/analysis.py @@ -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: @@ -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) diff --git a/enlopy/generate.py b/enlopy/generate.py index 06de484..33c429b 100644 --- a/enlopy/generate.py +++ b/enlopy/generate.py @@ -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.. @@ -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 diff --git a/enlopy/plot.py b/enlopy/plot.py index c17f66a..e649b48 100644 --- a/enlopy/plot.py +++ b/enlopy/plot.py @@ -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', diff --git a/environment.yml b/environment.yml index 957a913..b5808d2 100644 --- a/environment.yml +++ b/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 diff --git a/setup.py b/setup.py index 5247fff..c8d20eb 100644 --- a/setup.py +++ b/setup.py @@ -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", @@ -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,