Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • berntm/saqc
  • rdm-software/saqc
  • schueler/saqc
3 results
Show changes
Commits on Source (4)
Showing
with 6 additions and 43 deletions
...@@ -47,7 +47,6 @@ class _DiosBase: ...@@ -47,7 +47,6 @@ class _DiosBase:
cast_policy="save", cast_policy="save",
fastpath=False, fastpath=False,
): ):
self._attrs = {} self._attrs = {}
self.cast_policy = cast_policy # set via property self.cast_policy = cast_policy # set via property
...@@ -62,7 +61,6 @@ class _DiosBase: ...@@ -62,7 +61,6 @@ class _DiosBase:
self._data = pd.Series(dtype="O", index=columns) self._data = pd.Series(dtype="O", index=columns)
else: else:
if index is not None and not isinstance(index, pd.Index): if index is not None and not isinstance(index, pd.Index):
index = pd.Index(index) index = pd.Index(index)
...@@ -295,7 +293,6 @@ class _DiosBase: ...@@ -295,7 +293,6 @@ class _DiosBase:
self._data.at[c][series.index] = series self._data.at[c][series.index] = series
def _setitem_listlike(self, data, value): def _setitem_listlike(self, data, value):
value = value.values if isinstance(value, pd.Series) else value value = value.values if isinstance(value, pd.Series) else value
if len(value) != len(data.columns): if len(value) != len(data.columns):
......
...@@ -15,7 +15,6 @@ class _Indexer: ...@@ -15,7 +15,6 @@ class _Indexer:
self._data = obj._data self._data = obj._data
def _unpack_key(self, key): def _unpack_key(self, key):
key = list(key) if pdextra.is_iterator(key) else key key = list(key) if pdextra.is_iterator(key) else key
if isinstance(key, tuple): if isinstance(key, tuple):
...@@ -89,7 +88,6 @@ class _LocIndexer(_Indexer): ...@@ -89,7 +88,6 @@ class _LocIndexer(_Indexer):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
def __getitem__(self, key): def __getitem__(self, key):
rowkey, colkey = self._unpack_key(key) rowkey, colkey = self._unpack_key(key)
if _is_dios_like(rowkey) or _is_dios_like(colkey): if _is_dios_like(rowkey) or _is_dios_like(colkey):
raise ValueError("Could not index with multidimensional key") raise ValueError("Could not index with multidimensional key")
...@@ -109,7 +107,6 @@ class _LocIndexer(_Indexer): ...@@ -109,7 +107,6 @@ class _LocIndexer(_Indexer):
else: else:
k = "?" k = "?"
try: try:
for k in data.index: for k in data.index:
data.at[k] = data.at[k].loc[rowkey] data.at[k] = data.at[k].loc[rowkey]
...@@ -128,14 +125,12 @@ class _LocIndexer(_Indexer): ...@@ -128,14 +125,12 @@ class _LocIndexer(_Indexer):
return new return new
def __setitem__(self, key, value): def __setitem__(self, key, value):
rowkey, colkey = self._unpack_key(key) rowkey, colkey = self._unpack_key(key)
if _is_dios_like(rowkey) or _is_dios_like(colkey): if _is_dios_like(rowkey) or _is_dios_like(colkey):
raise ValueError("Cannot index with multi-dimensional key") raise ValueError("Cannot index with multi-dimensional key")
# .loc[any, scalar] - set on single column # .loc[any, scalar] - set on single column
if pdextra.is_hashable(colkey): if pdextra.is_hashable(colkey):
# .loc[dont-care, new-scalar] = val # .loc[dont-care, new-scalar] = val
if colkey not in self.obj.columns: if colkey not in self.obj.columns:
self.obj._insert(colkey, value) self.obj._insert(colkey, value)
...@@ -180,7 +175,6 @@ class _iLocIndexer(_Indexer): ...@@ -180,7 +175,6 @@ class _iLocIndexer(_Indexer):
else: else:
k = "?" k = "?"
try: try:
for k in data.index: for k in data.index:
data.at[k] = data.at[k].iloc[rowkey] data.at[k] = data.at[k].iloc[rowkey]
...@@ -248,7 +242,6 @@ class _aLocIndexer(_Indexer): ...@@ -248,7 +242,6 @@ class _aLocIndexer(_Indexer):
c = "?" c = "?"
try: try:
for i, c in enumerate(data.index): for i, c in enumerate(data.index):
data.at[c] = self._data.at[c].loc[rowkeys[i]] data.at[c] = self._data.at[c].loc[rowkeys[i]]
...@@ -268,7 +261,6 @@ class _aLocIndexer(_Indexer): ...@@ -268,7 +261,6 @@ class _aLocIndexer(_Indexer):
def iter_self(colkeys, position=False): def iter_self(colkeys, position=False):
c = "?" c = "?"
try: try:
for i, c in enumerate(colkeys): for i, c in enumerate(colkeys):
dat = self._data.at[c] dat = self._data.at[c]
rk = rowkeys[i] rk = rowkeys[i]
...@@ -347,7 +339,6 @@ class _aLocIndexer(_Indexer): ...@@ -347,7 +339,6 @@ class _aLocIndexer(_Indexer):
# .aloc[dios] # .aloc[dios]
if _is_dios_like(rowkey): if _is_dios_like(rowkey):
if not pdextra.is_null_slice(colkey): if not pdextra.is_null_slice(colkey):
raise ValueError( raise ValueError(
f"Could not index with a dios-like indexer as rowkey," f"Could not index with a dios-like indexer as rowkey,"
...@@ -385,7 +376,6 @@ class _aLocIndexer(_Indexer): ...@@ -385,7 +376,6 @@ class _aLocIndexer(_Indexer):
return rowkey, colkey, lowdim return rowkey, colkey, lowdim
def _get_rowkey(self, rowkey, colkey, depth=0): def _get_rowkey(self, rowkey, colkey, depth=0):
if pdextra.is_nested_list_like(rowkey) and depth == 0: if pdextra.is_nested_list_like(rowkey) and depth == 0:
rowkey = rowkey.values if isinstance(rowkey, pd.Series) else rowkey rowkey = rowkey.values if isinstance(rowkey, pd.Series) else rowkey
if len(rowkey) != len(colkey): if len(rowkey) != len(colkey):
......
...@@ -25,7 +25,6 @@ def _gen_testset(rowsz, colsz, freq="1min", disalign=True, randstart=True): ...@@ -25,7 +25,6 @@ def _gen_testset(rowsz, colsz, freq="1min", disalign=True, randstart=True):
freqv = int(freq[: -len(frequ)]) freqv = int(freq[: -len(frequ)])
for i in range(colsz): for i in range(colsz):
if randstart: if randstart:
# generate random startpoint for each series # generate random startpoint for each series
r = str(np.random.randint(int(rowsz * 0.05), int(rowsz * 0.6) + 2)) + frequ r = str(np.random.randint(int(rowsz * 0.05), int(rowsz * 0.6) + 2)) + frequ
......
...@@ -40,7 +40,6 @@ def rows_by_time(nsec, mdays): ...@@ -40,7 +40,6 @@ def rows_by_time(nsec, mdays):
if __name__ == "__main__": if __name__ == "__main__":
# dios - linear in rows and colums, same size for r=10,c=100 or r=100,c=10 # dios - linear in rows and colums, same size for r=10,c=100 or r=100,c=10
do_real_check = True do_real_check = True
cols = 10 cols = 10
......
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
numpy==1.21.2 numpy==1.21.2
pandas==1.3.5 pandas==1.3.5
python-dateutil==2.8.2 python-dateutil==2.8.2
pytz==2022.2.1 pytz==2022.7.1
six==1.16.0 six==1.16.0
...@@ -33,7 +33,6 @@ TESTDATA = [ ...@@ -33,7 +33,6 @@ TESTDATA = [
@pytest.mark.parametrize("data", TESTDATA) @pytest.mark.parametrize("data", TESTDATA)
@pytest.mark.parametrize("with_column_param", [False, True]) @pytest.mark.parametrize("with_column_param", [False, True])
def test_dios_create(data, with_column_param): def test_dios_create(data, with_column_param):
data_copy0 = deepcopy(data) data_copy0 = deepcopy(data)
data_copy1 = deepcopy(data) data_copy1 = deepcopy(data)
......
...@@ -8,7 +8,6 @@ from .test_setup import * ...@@ -8,7 +8,6 @@ from .test_setup import *
def _test(res, exp): def _test(res, exp):
if isinstance(exp, pd.DataFrame): if isinstance(exp, pd.DataFrame):
eq, msg = dios_eq_df(res, exp, with_msg=True) eq, msg = dios_eq_df(res, exp, with_msg=True)
assert eq, msg assert eq, msg
......
...@@ -8,5 +8,5 @@ sphinx-automodapi==0.14.1 ...@@ -8,5 +8,5 @@ sphinx-automodapi==0.14.1
sphinxcontrib-fulltoc==1.2.0 sphinxcontrib-fulltoc==1.2.0
sphinx-markdown-tables==0.0.17 sphinx-markdown-tables==0.0.17
jupyter-sphinx==0.3.2 jupyter-sphinx==0.3.2
sphinx_autodoc_typehints==1.18.2 sphinx_autodoc_typehints==1.22
sphinx-tabs==3.4.1 sphinx-tabs==3.4.1
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
Click==8.1.3 Click==8.1.3
dtw==1.4.0 dtw==1.4.0
matplotlib==3.6.2 matplotlib==3.6.3
numba==0.56.4 numba==0.56.4
numpy==1.23.5 numpy==1.23.5
outlier-utils==0.0.3 outlier-utils==0.0.3
pyarrow==10.0.1 pyarrow==11.0.0
pandas==1.3.5 pandas==1.3.5
scikit-learn==1.2.0 scikit-learn==1.2.1
scipy==1.10.0 scipy==1.10.0
typing_extensions==4.4.0 typing_extensions==4.4.0
...@@ -117,7 +117,6 @@ def main(config, data, scheme, outfile, nodata, log_level): ...@@ -117,7 +117,6 @@ def main(config, data, scheme, outfile, nodata, log_level):
flags_result = flags_result.to_df() flags_result = flags_result.to_df()
if outfile: if outfile:
data_result.columns = pd.MultiIndex.from_product( data_result.columns = pd.MultiIndex.from_product(
[data_result.columns.tolist(), ["data"]] [data_result.columns.tolist(), ["data"]]
) )
......
...@@ -56,6 +56,7 @@ BAD = 255.0 ...@@ -56,6 +56,7 @@ BAD = 255.0
FILTER_ALL = -np.inf FILTER_ALL = -np.inf
FILTER_NONE = np.inf FILTER_NONE = np.inf
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# other # other
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
......
...@@ -152,7 +152,6 @@ class SaQC(FunctionsMixin): ...@@ -152,7 +152,6 @@ class SaQC(FunctionsMixin):
) )
def _initData(self, data) -> DictOfSeries: def _initData(self, data) -> DictOfSeries:
if data is None: if data is None:
return DictOfSeries() return DictOfSeries()
......
...@@ -192,7 +192,6 @@ class Flags: ...@@ -192,7 +192,6 @@ class Flags:
""" """
def __init__(self, raw_data: DictLike | Flags | None = None, copy: bool = False): def __init__(self, raw_data: DictLike | Flags | None = None, copy: bool = False):
self._data: dict[str, History] self._data: dict[str, History]
if raw_data is None: if raw_data is None:
...@@ -215,7 +214,6 @@ class Flags: ...@@ -215,7 +214,6 @@ class Flags:
result = {} result = {}
for k, item in data.items(): for k, item in data.items():
if not isinstance(k, str): if not isinstance(k, str):
raise ValueError("column names must be string") raise ValueError("column names must be string")
if k in result: if k in result:
...@@ -524,7 +522,6 @@ def initFlagsLike( ...@@ -524,7 +522,6 @@ def initFlagsLike(
reference = reference.to_frame(name=name) reference = reference.to_frame(name=name)
for k, item in reference.items(): for k, item in reference.items():
if not isinstance(k, str): if not isinstance(k, str):
raise TypeError( raise TypeError(
f"cannot use '{k}' as a column name, currently only string keys are allowed" f"cannot use '{k}' as a column name, currently only string keys are allowed"
......
...@@ -45,7 +45,6 @@ class History: ...@@ -45,7 +45,6 @@ class History:
""" """
def __init__(self, index: pd.Index | None): def __init__(self, index: pd.Index | None):
self._hist = pd.DataFrame(index=index) self._hist = pd.DataFrame(index=index)
self._meta = [] self._meta = []
...@@ -451,7 +450,6 @@ class History: ...@@ -451,7 +450,6 @@ class History:
return len(self._hist.columns) return len(self._hist.columns)
def __repr__(self): def __repr__(self):
if self.empty: if self.empty:
return str(self._hist).replace("DataFrame", "History") return str(self._hist).replace("DataFrame", "History")
......
...@@ -44,7 +44,6 @@ def _closeFile(fobj): ...@@ -44,7 +44,6 @@ def _closeFile(fobj):
def readFile(fname) -> pd.DataFrame: def readFile(fname) -> pd.DataFrame:
fobj = _openFile(fname) fobj = _openFile(fname)
out = [] out = []
...@@ -81,7 +80,6 @@ def fromConfig(fname, *args, **func_kwargs): ...@@ -81,7 +80,6 @@ def fromConfig(fname, *args, **func_kwargs):
config = readFile(fname) config = readFile(fname)
for _, field, expr in config.itertuples(): for _, field, expr in config.itertuples():
regex = False regex = False
if isQuoted(field): if isQuoted(field):
fld = field[1:-1] fld = field[1:-1]
......
...@@ -136,7 +136,6 @@ def _squeezeFlags(old_flags, new_flags: Flags, columns: pd.Index, meta) -> Flags ...@@ -136,7 +136,6 @@ def _squeezeFlags(old_flags, new_flags: Flags, columns: pd.Index, meta) -> Flags
for col in columns.union( for col in columns.union(
new_flags.columns.difference(old_flags.columns) new_flags.columns.difference(old_flags.columns)
): # account for newly added columns ): # account for newly added columns
if col not in out: # ensure existence if col not in out: # ensure existence
out.history[col] = History(index=new_flags.history[col].index) out.history[col] = History(index=new_flags.history[col].index)
...@@ -202,7 +201,6 @@ def _unmaskData( ...@@ -202,7 +201,6 @@ def _unmaskData(
columns = mask.columns.intersection(columns) columns = mask.columns.intersection(columns)
for c in columns: for c in columns:
# ignore # ignore
if data[c].empty or mask[c].empty: if data[c].empty or mask[c].empty:
continue continue
...@@ -315,7 +313,6 @@ def register( ...@@ -315,7 +313,6 @@ def register(
""" """
def outer(func: Callable[P, SaQC]) -> Callable[P, SaQC]: def outer(func: Callable[P, SaQC]) -> Callable[P, SaQC]:
func_signature = inspect.signature(func) func_signature = inspect.signature(func)
_checkDecoratorKeywords( _checkDecoratorKeywords(
func_signature, func.__name__, mask, demask, squeeze, handles_target func_signature, func.__name__, mask, demask, squeeze, handles_target
...@@ -330,7 +327,6 @@ def register( ...@@ -330,7 +327,6 @@ def register(
flag: ExternalFlag | OptionalNone = OptionalNone(), flag: ExternalFlag | OptionalNone = OptionalNone(),
**kwargs, **kwargs,
) -> "SaQC": ) -> "SaQC":
# args -> kwargs # args -> kwargs
paramnames = tuple(func_signature.parameters.keys())[ paramnames = tuple(func_signature.parameters.keys())[
2: 2:
......
...@@ -200,7 +200,6 @@ class FloatScheme(TranslationScheme): ...@@ -200,7 +200,6 @@ class FloatScheme(TranslationScheme):
DFILTER_DEFAULT: float = FILTER_ALL DFILTER_DEFAULT: float = FILTER_ALL
def __call__(self, flag: float | int) -> float: def __call__(self, flag: float | int) -> float:
try: try:
return float(flag) return float(flag)
except (TypeError, ValueError, OverflowError): except (TypeError, ValueError, OverflowError):
......
...@@ -139,7 +139,6 @@ class DmpScheme(MappingScheme): ...@@ -139,7 +139,6 @@ class DmpScheme(MappingScheme):
) )
for field in tflags.columns: for field in tflags.columns:
df = pd.DataFrame( df = pd.DataFrame(
{ {
"quality_flag": tflags[field], "quality_flag": tflags[field],
...@@ -150,7 +149,6 @@ class DmpScheme(MappingScheme): ...@@ -150,7 +149,6 @@ class DmpScheme(MappingScheme):
history = flags.history[field] history = flags.history[field]
for col in history.columns: for col in history.columns:
valid = (history.hist[col] != UNFLAGGED) & history.hist[col].notna() valid = (history.hist[col] != UNFLAGGED) & history.hist[col].notna()
# extract from meta # extract from meta
...@@ -191,7 +189,6 @@ class DmpScheme(MappingScheme): ...@@ -191,7 +189,6 @@ class DmpScheme(MappingScheme):
) )
for field in df.columns.get_level_values(0): for field in df.columns.get_level_values(0):
# we might have NaN injected by DictOfSeries -> DataFrame conversions # we might have NaN injected by DictOfSeries -> DataFrame conversions
field_df = df[field].dropna(how="all", axis="index") field_df = df[field].dropna(how="all", axis="index")
flags = field_df["quality_flag"] flags = field_df["quality_flag"]
......
...@@ -59,7 +59,6 @@ class PositionalScheme(MappingScheme): ...@@ -59,7 +59,6 @@ class PositionalScheme(MappingScheme):
data = {} data = {}
for field, field_flags in flags.items(): for field, field_flags in flags.items():
# explode the flags into sperate columns and drop the leading `9` # explode the flags into sperate columns and drop the leading `9`
df = pd.DataFrame( df = pd.DataFrame(
field_flags.astype(str).str.slice(start=1).apply(tuple).tolist(), field_flags.astype(str).str.slice(start=1).apply(tuple).tolist(),
......
...@@ -81,7 +81,6 @@ class ConfigExpressionParser(ast.NodeVisitor): ...@@ -81,7 +81,6 @@ class ConfigExpressionParser(ast.NodeVisitor):
class ConfigFunctionParser(ast.NodeVisitor): class ConfigFunctionParser(ast.NodeVisitor):
SUPPORTED_NODES = ( SUPPORTED_NODES = (
ast.Call, ast.Call,
ast.Num, ast.Num,
...@@ -107,7 +106,6 @@ class ConfigFunctionParser(ast.NodeVisitor): ...@@ -107,7 +106,6 @@ class ConfigFunctionParser(ast.NodeVisitor):
return func, self.kwargs return func, self.kwargs
def visit_Call(self, node): def visit_Call(self, node):
if not isinstance(node, ast.Call): if not isinstance(node, ast.Call):
raise TypeError("expected function call") raise TypeError("expected function call")
...@@ -126,7 +124,6 @@ class ConfigFunctionParser(ast.NodeVisitor): ...@@ -126,7 +124,6 @@ class ConfigFunctionParser(ast.NodeVisitor):
return func_name return func_name
def visit_keyword(self, node): def visit_keyword(self, node):
key, value = node.arg, node.value key, value = node.arg, node.value
check_tree = True check_tree = True
......