Skip to content
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

Release 1.3.0 #107

Merged
merged 29 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3b909fc
clearer marking per ytick for data_availability
martinvonk Aug 2, 2023
0c28053
clearer markers for yticks in data_availability plot
martinvonk Aug 2, 2023
094a6c6
Merge branch 'dev' of https://github.com/pastas/pastastore into dev
martinvonk Aug 2, 2023
a20ba0e
Update plotting.py
martinvonk Aug 2, 2023
5e807a2
check _d and _a for steptrend and linear trend
martinvonk Aug 16, 2023
43d0ef4
steptrend is named stepmodel
martinvonk Aug 28, 2023
3b8bb0b
add apply func #99 + two fixes
dbrakenhoff Sep 7, 2023
15f3bcb
add docstring
dbrakenhoff Sep 7, 2023
2c919a0
first attempt to add signatures to pastastore
OnnoEbbens Sep 7, 2023
2799b64
Merge pull request #100 from pastas/applyfunc
dbrakenhoff Sep 7, 2023
c006bce
fix variable name
OnnoEbbens Sep 7, 2023
c0d9b8b
add default Connector
dbrakenhoff Sep 10, 2023
6cf415f
Merge pull request #103 from pastas/default_connector
dbrakenhoff Sep 18, 2023
fb7523a
fix for comment
OnnoEbbens Oct 17, 2023
9281957
improve empty library
dbrakenhoff Oct 24, 2023
6767be3
add get_extent to PastaStore
dbrakenhoff Oct 24, 2023
d3ded76
Merge pull request #101 from pastas/gw_signatures
dbrakenhoff Oct 24, 2023
8d90e16
black
dbrakenhoff Oct 24, 2023
2b66f79
Merge pull request #106 from pastas/add_get_extent
dbrakenhoff Oct 24, 2023
fee2fd4
Merge pull request #105 from pastas/improve_empty_library
dbrakenhoff Oct 24, 2023
a4ffe3e
add buffer kwarg to extent
dbrakenhoff Oct 26, 2023
7fc459f
PastaStore.apply returns dataframe
dbrakenhoff Oct 26, 2023
d6d44e7
version
dbrakenhoff Oct 26, 2023
0ec3a44
apply should return dict, not DataFrame
dbrakenhoff Oct 26, 2023
3c434f6
improve default Connectors
dbrakenhoff Nov 1, 2023
38e6a49
codacy
dbrakenhoff Nov 1, 2023
a4a2bc4
fix for #108
OnnoEbbens Nov 14, 2023
cdd964d
Merge pull request #109 from pastas/108-problems-with-float-to-int-co…
dbrakenhoff Nov 14, 2023
07a0eb2
ruff
dbrakenhoff Nov 27, 2023
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
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import sys

sys.path.insert(0, os.path.abspath("."))
from pastastore import __version__
from pastastore import __version__ # noqa: E402

# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -125,7 +125,6 @@
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
Expand Down
4 changes: 0 additions & 4 deletions examples/notebooks/ex02_pastastore_plots_and_maps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import os\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import pastastore as pst\n",
"import pastas as ps\n",
Expand Down
8 changes: 4 additions & 4 deletions examples/notebooks/ex03_pastastore_yaml_interface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"metadata": {},
"outputs": [],
"source": [
"from pastastore.datasets import example_pastastore"
"from pastastore.datasets import example_pastastore # noqa: E402"
]
},
{
Expand Down Expand Up @@ -364,7 +364,7 @@
],
"source": [
"ml.solve(report=False)\n",
"ml.plots.results();"
"ml.plots.results()"
]
},
{
Expand Down Expand Up @@ -802,7 +802,7 @@
],
"source": [
"ml.solve(report=False)\n",
"ml.plots.results();"
"ml.plots.results()"
]
},
{
Expand Down Expand Up @@ -910,7 +910,7 @@
],
"source": [
"ml.solve(report=False)\n",
"ml.plots.results();"
"ml.plots.results()"
]
},
{
Expand Down
9 changes: 5 additions & 4 deletions pastastore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from . import connectors, util
from .connectors import (
# ruff: noqa: F401
from pastastore import connectors, util
from pastastore.connectors import (
ArcticConnector,
ArcticDBConnector,
DictConnector,
PasConnector,
PystoreConnector,
)
from .store import PastaStore
from .version import __version__
from pastastore.store import PastaStore
from pastastore.version import __version__
31 changes: 21 additions & 10 deletions pastastore/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from numpy import isin
from packaging.version import parse as parse_version
from pastas.io.pas import PastasEncoder
from tqdm import tqdm
from tqdm.auto import tqdm
dbrakenhoff marked this conversation as resolved.
Show resolved Hide resolved

from .util import ItemInLibraryException, _custom_warning, validate_names
from .version import PASTAS_LEQ_022
from pastastore.util import ItemInLibraryException, _custom_warning, validate_names
from pastastore.version import PASTAS_LEQ_022

FrameorSeriesUnion = Union[pd.DataFrame, pd.Series]
warnings.showwarning = _custom_warning
Expand Down Expand Up @@ -934,13 +934,24 @@ def empty_library(
)
if ui.lower() != "y":
return
names = self._parse_names(None, libname)
for name in (
tqdm(names, desc=f"Deleting items from {libname}") if progressbar else names
):
self._del_item(libname, name)
self._clear_cache(libname)
print(f"Emptied library {libname} in {self.name}: " f"{self.__class__}")

if libname == "models":
# also delete linked modelnames linked to oseries
libs = ["models", "oseries_models"]
else:
libs = [libname]

# delete items and clear caches
for libname in libs:
names = self._parse_names(None, libname)
for name in (
tqdm(names, desc=f"Deleting items from {libname}")
if progressbar
else names
):
self._del_item(libname, name)
self._clear_cache(libname)
print(f"Emptied library {libname} in {self.name}: " f"{self.__class__}")

def _iter_series(self, libname: str, names: Optional[List[str]] = None):
"""Internal method iterate over time series in library.
Expand Down
4 changes: 2 additions & 2 deletions pastastore/connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import pandas as pd
from pastas.io.pas import PastasEncoder, pastas_hook

from .base import BaseConnector, ConnectorUtil, ModelAccessor
from .util import _custom_warning
from pastastore.base import BaseConnector, ConnectorUtil, ModelAccessor
from pastastore.util import _custom_warning

FrameorSeriesUnion = Union[pd.DataFrame, pd.Series]
warnings.showwarning = _custom_warning
Expand Down
33 changes: 21 additions & 12 deletions pastastore/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
ax = pstore.maps.oseries()
pstore.maps.add_background_map(ax) # for adding a background map
"""

from collections.abc import Iterable

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -96,15 +93,11 @@ def _timeseries(

if ax is None:
if split:
fig, axes = plt.subplots(len(names), 1, sharex=True, figsize=figsize)
_, axes = plt.subplots(len(names), 1, sharex=True, figsize=figsize)
else:
fig, axes = plt.subplots(1, 1, figsize=figsize)
_, axes = plt.subplots(1, 1, figsize=figsize)
else:
axes = ax
if isinstance(axes, Iterable):
fig = axes[0].figure
else:
fig = axes.figure

tsdict = self.pstore.conn._get_series(
libname, names, progressbar=progressbar, squeeze=False
Expand Down Expand Up @@ -397,20 +390,31 @@ def _data_availability(
linewidth=0,
rasterized=True,
)

# make a colorbar in an ax on the
# right side, then set the current axes to ax again
cb = fig.colorbar(pc, ax=ax, cax=cax, extend="both")
cb.set_ticks(bounds)
cb.ax.set_yticklabels(labels)
cb.ax.minorticks_off()

if set_yticks:
ax.set_yticks(np.arange(0.5, len(series) + 0.5))
ax.set_yticks(np.arange(0.5, len(series) + 0.5), minor=False)
ax.set_yticks(np.arange(0, len(series) + 1), minor=True)
if names is None:
names = [s.name for s in series]
ax.set_yticklabels(names)

for tick in ax.yaxis.get_major_ticks(): # don't show major ytick marker
tick.tick1line.set_visible(False)

ax.grid(True, which="minor", axis="y")
ax.grid(True, which="major", axis="x")

else:
ax.set_ylabel("Timeseries (-)")
ax.grid(True)
ax.grid(True, which="both")
ax.grid(True, which="both")

return ax

Expand Down Expand Up @@ -712,6 +716,7 @@ def models(
def modelstat(
self,
statistic,
modelnames=None,
label=True,
adjust=False,
cmap="viridis",
Expand All @@ -728,6 +733,8 @@ def modelstat(
----------
statistic: str
name of the statistic, e.g. "evp" or "aic"
modelnames : list of str, optional
list of modelnames to include
label: bool, optional
label points, by default True
adjust: bool, optional
Expand Down Expand Up @@ -757,7 +764,9 @@ def modelstat(
--------
self.add_background_map
"""
statsdf = self.pstore.get_statistics([statistic], progressbar=False).to_frame()
statsdf = self.pstore.get_statistics(
[statistic], modelnames=modelnames, progressbar=False
).to_frame()

statsdf["oseries"] = [
self.pstore.get_models(m, return_dict=True)["oseries"]["name"]
Expand Down
Loading