Skip to content
Snippets Groups Projects
Commit 1ec54cbe authored by Bert Palm's avatar Bert Palm 🎇
Browse files

a snake is trampled by a camel

parent e263e20d
No related branches found
No related tags found
4 merge requests!271Static expansion of regular expressions,!260Follow-Up Translations,!237Flagger Translations,!232WIP: Fuzzy testing
......@@ -20,7 +20,7 @@ import timeit
import inspect
from saqc.common import *
from saqc.flagger import init_flags_like, Flagger
from saqc.flagger import initFlagsLike, Flagger
from saqc.core.lib import APIController, ColumnSelector
from saqc.core.register import FUNC_MAP, SaQCFunction
from saqc.core.modules import FuncModules
......@@ -123,7 +123,7 @@ class SaQC(FuncModules):
a flags frame or an already initialised flagger are used.
"""
if flagger is None:
return init_flags_like(data)
return initFlagsLike(data)
for c in flagger.columns.union(data.columns):
if c in flagger:
......
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from .flags import Flagger, init_flags_like
from .flags import Flagger, initFlagsLike
from .history import History
......@@ -57,8 +57,8 @@ class Flags:
conversion
----------
make a dios -> flags.to_dios()
make a df -> flags.to_frame()
make a dios -> flags.toDios()
make a df -> flags.toFrame()
"""
def __init__(self, raw_data: Optional[Union[DictLike, Flags]] = None, copy: bool = False):
......@@ -70,7 +70,7 @@ class Flags:
raw_data = raw_data._data
# with python 3.7 dicts are insertion-ordered by default
self._data = self._init_from_raw(raw_data, copy)
self._data = self._initFromRaw(raw_data, copy)
# this is a simple cache that reduce the calculation of the flags
# from the entire history of a flag column. The _cache is filled
......@@ -79,7 +79,7 @@ class Flags:
# have to much trouble.
self._cache = {}
def _init_from_raw(self, data, copy) -> Dict[str, History]:
def _initFromRaw(self, data, copy) -> Dict[str, History]:
"""
init from dict-like: keys are flag column, values become
initial columns of history(s).
......@@ -245,7 +245,7 @@ class Flags:
# ----------------------------------------------------------------------
# transformation and representation
def to_dios(self) -> dios.DictOfSeries:
def toDios(self) -> dios.DictOfSeries:
di = dios.DictOfSeries(columns=self.columns)
for k, v in self._data.items():
......@@ -253,14 +253,14 @@ class Flags:
return di.copy()
def to_frame(self) -> pd.DataFrame:
return self.to_dios().to_df()
def toFrame(self) -> pd.DataFrame:
return self.toDios().to_df()
def __repr__(self) -> str:
return str(self.to_dios()).replace('DictOfSeries', type(self).__name__)
return str(self.toDios()).replace('DictOfSeries', type(self).__name__)
def init_flags_like(reference: Union[pd.Series, DictLike, Flags], initial_value: float = UNFLAGGED) -> Flags:
def initFlagsLike(reference: Union[pd.Series, DictLike, Flags], initial_value: float = UNFLAGGED) -> Flags:
"""
Create empty Flags, from an reference data structure.
......
......@@ -181,7 +181,7 @@ def test_cache():
assert 'a' not in flags._cache
# cache all
flags.to_dios()
flags.toDios()
for c in flags.columns:
assert c in flags._cache
......@@ -202,7 +202,7 @@ def _validate_flags_equals_frame(flags, df):
@pytest.mark.parametrize('data', data)
def test_to_dios(data: np.array):
flags = Flags(data)
df = flags.to_dios()
df = flags.toDios()
assert isinstance(df, dios.DictOfSeries)
_validate_flags_equals_frame(flags, df)
......@@ -211,7 +211,7 @@ def test_to_dios(data: np.array):
@pytest.mark.parametrize('data', data)
def test_to_frame(data: np.array):
flags = Flags(data)
df = flags.to_frame()
df = flags.toFrame()
assert isinstance(df, pd.DataFrame)
_validate_flags_equals_frame(flags, df)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment