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

add default Connector #103

Merged
merged 1 commit into from
Sep 18, 2023
Merged
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
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
#
# html_sidebars = {}


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

# Output file base name for HTML help builder.
Expand Down
8 changes: 4 additions & 4 deletions pastastore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from . import connectors, util
from .connectors import (
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__
4 changes: 2 additions & 2 deletions pastastore/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from pastas.io.pas import PastasEncoder
from tqdm.auto import tqdm

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
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
20 changes: 13 additions & 7 deletions pastastore/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
from pastas.io.pas import pastas_hook
from tqdm.auto import tqdm

from .plotting import Maps, Plots
from .util import _custom_warning
from .yaml_interface import PastastoreYAML
from pastastore.base import BaseConnector
from pastastore.connectors import DictConnector
from pastastore.plotting import Maps, Plots
from pastastore.util import _custom_warning
from pastastore.yaml_interface import PastastoreYAML

FrameorSeriesUnion = Union[pd.DataFrame, pd.Series]
warnings.showwarning = _custom_warning
Expand All @@ -38,14 +40,18 @@ class PastaStore:
name of the PastaStore, by default takes the name of the Connector object
"""

def __init__(self, connector, name: str = None):
def __init__(
self,
connector: BaseConnector = DictConnector("pastas_db"),
name: Optional[str] = None,
):
"""Initialize PastaStore for managing pastas time series and models.

Parameters
----------
connector : Connector object
object that provides the interface to the
database
connector : Connector object, optional
object that provides the connection to the database. Default is
DictConnector which does not store data on disk.
name : str, optional
name of the PastaStore, if not provided uses the Connector name
"""
Expand Down
2 changes: 1 addition & 1 deletion pastastore/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pastas.stats.tests import runs_test, stoffer_toloi
from tqdm.auto import tqdm

from .version import PASTAS_LEQ_022
from pastastore.version import PASTAS_LEQ_022


def _custom_warning(message, category=UserWarning, filename="", lineno=-1, *args):
Expand Down
2 changes: 1 addition & 1 deletion pastastore/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
PASTAS_VERSION = parse_version(ps.__version__)
PASTAS_LEQ_022 = PASTAS_VERSION <= parse_version("0.22.0")

__version__ = "1.2.2"
__version__ = "1.3.0b"
6 changes: 3 additions & 3 deletions pastastore/yaml_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
import logging
import os
from copy import deepcopy
from typing import Dict, List, Optional, Union
from typing import Any, Dict, List, Optional, Union

import numpy as np
import pandas as pd
import pastas as ps
import yaml

from .version import PASTAS_LEQ_022
from pastastore.version import PASTAS_LEQ_022

ps.logger.setLevel("ERROR")

logging.basicConfig(level="INFO")
logger = logging.getLogger(__name__)


def _convert_dict_dtypes_for_yaml(d: Dict):
def _convert_dict_dtypes_for_yaml(d: Dict[str, Any]):
"""Internal method to convert dictionary values for storing in YAML format.

Parameters
Expand Down