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 (16)
numpy==1.19.1
pandas==1.1.1
pandas==1.2.4
python-dateutil==2.8.1
pytz==2020.1
pytz==2021.1
six==1.15.0
Click==7.1.2
dtw==1.4.0
hypothesis==6.8.3
hypothesis==6.10.1
matplotlib==3.4.1
mlxtend==0.18.0
numba==0.53.1
numpy==1.20.2
outlier-utils==0.0.3
pandas==1.2.3
pandas==1.2.4
pyarrow==3.0.0
pytest==6.2.2
pytest==6.2.3
pytest-lazy-fixture==0.6.3
PyWavelets==1.1.1
scikit-learn==0.24.1
scipy==1.6.2
scikit-learn==0.24.2
scipy==1.6.3
typing_extensions==3.7.4.3
......@@ -255,7 +255,7 @@ class History:
value_mask = value_mask.iloc[:, n:]
# rename columns, to avoid ``pd.DataFrame.loc`` become confused
columns = pd.Index(range(n, len(value_hist.columns) + 1))
columns = pd.Index(range(n, n + len(value_hist.columns)))
value_hist.columns = columns
value_mask.columns = columns
......
......@@ -11,7 +11,7 @@ import warnings
from saqc.constants import *
from saqc.core.lib import SaQCFunction
from saqc.core.flags import initFlagsLike, Flags
from saqc.lib.types import FuncReturnT
# NOTE:
# the global SaQC function store,
......@@ -19,6 +19,7 @@ from saqc.lib.types import FuncReturnT
FUNC_MAP: Dict[str, SaQCFunction] = {}
MaskingStrT = Literal["all", "field", "none"]
FuncReturnT = Tuple[dios.DictOfSeries, Flags]
@dataclasses.dataclass
......@@ -185,7 +186,7 @@ def _getMaskingThresh(masking, kwargs, fname):
The kwargs that will be passed to the saqc-function, possibly contain ``to_mask``.
fname : str
The name of the saqc-function to be called later (not here), to use in meaningful
error messages
error messages
Returns
-------
......@@ -212,7 +213,7 @@ def _getMaskingThresh(masking, kwargs, fname):
if masking == "none" and thresh not in (False, np.inf):
# TODO: fix warning reference to docu
warnings.warn(
f"the saqc-function {fname!r} ignore masking and therefore does not evaluate the passed "
f"the saqc-function {fname!r} ignores masking and therefore does not evaluate the passed "
f"'to_mask'-keyword. Please refer to the documentation: TODO"
)
......@@ -283,7 +284,7 @@ def _prepareFlags(flags: Flags, masking) -> Flags:
if masking == "none":
return flags.copy()
return initFlagsLike(flags, initial_value=UNTOUCHED)
return initFlagsLike(flags)
def _restoreFlags(flags: Flags, old_state: CallState):
......@@ -298,10 +299,17 @@ def _restoreFlags(flags: Flags, old_state: CallState):
out = old_state.flags.copy()
for c in columns:
# this implicitly squash the new flags history (RHS) to a single column, which than is appended to
# the old history (LHS). The new flags history possibly consist of multiple columns, one for each
# time a series or scalar was passed to the flags.
out[c] = flags[c]
# this implicitly squash the new flags history (RHS)
# to a single column, which than is appended to the
# old history (LHS). The new flags history possibly
# consists of multiple columns, one for each time a
# series or scalar was passed to the flags.
if len(flags.history[c].columns) > 1 or c not in out:
# We only want to assign a new column to our history
# if something changed on the RHS, or if a new variable
# appeared. Otherwise blow up our history with dummy
# columns
out[c] = flags[c]
return out
......
......@@ -26,94 +26,17 @@ The documents and the docstrings then are collected and rendered using [sphinx](
- For one liner docstrings, please keep the closing `"""` on the same line.
[[PEP8](https://www.python.org/dev/peps/pep-0008/#documentation-strings)]
### Numpy Style
### Pandas Style
We use NumPy-style docstrings. Like this:
```python
def diag(v, k=0):
"""
Extract a diagonal or construct a diagonal array.
See the more detailed documentation for ``numpy.diagonal`` if you use this
function to extract a diagonal and wish to write to the resulting array;
whether it returns a copy or a view depends on what version of numpy you
are using.
Parameters
----------
v : array_like
If `v` is a 2-D array, return a copy of its `k`-th diagonal.
If `v` is a 1-D array, return a 2-D array with `v` on the `k`-th
diagonal.
k : int, optional
Diagonal in question. The default is 0. Use `k>0` for diagonals
above the main diagonal, and `k<0` for diagonals below the main
diagonal.
Returns
-------
out : ndarray
The extracted diagonal or constructed diagonal array.
See Also
--------
diagonal : Return specified diagonals.
diagflat : Create a 2-D array with the flattened input as a diagonal.
trace : Sum along diagonals.
triu : Upper triangle of an array.
tril : Lower triangle of an array.
Examples
--------
>>> x = np.arange(9).reshape((3,3))
>>> x
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
>>> np.diag(x)
array([0, 4, 8])
>>> np.diag(x, k=1)
array([1, 5])
>>> np.diag(x, k=-1)
array([3, 7])
>>> np.diag(np.diag(x))
array([[0, 0, 0],
[0, 4, 0],
[0, 0, 8]])
"""
```
We use [Pandas-style](https://pandas.pydata.org/pandas-docs/stable/development/contributing_docstring.html) docstrings:
For a description of the sections read the [numpydoc docstring guide](https://numpydoc.readthedocs.io/en/latest/format.html).
For a more descriptive, fully fledged example see [here](https://numpydoc.readthedocs.io/en/latest/example.html#example). Please use the official type hints, as defined in the [standard library module](https://docs.python.org/3/library/typing.html) `typing` wherever data type information is given.
But mostly the following sections are sufficient:
1. **Always give a *One-line summary***
2. optionally use *Extended summary*
2. **Always give the *Parameters* Section** with `typing` conform type descriptions
3. **Always give the *Returns* Section** with `typing` conform type descriptions
2. optionally use *See Also*
2. optionally use *Notes*
2. optionally use *Examples*
3. every other Section is even more optional :P
5. And **always check if the `-----` has the same length** as the word it underlines. Seriously, otherwise sphinx will mock, and its really no fun to find and correct these !.
```
See Also
--------
```
That's is ok, but following is **not**
```
See Also
---------
^
```
## Flags, data, field, etc.
## Flagger, data, field, etc.
use this:
```py
def foo(data, field, flags):
def foo(data, field, flagger):
"""
data : dios.DictOfSeries
A saqc-data object.
......@@ -121,8 +44,8 @@ def foo(data, field, flags):
field : str
A field denoting a column in data.
flags : saqc.Flags
A Flags object.
flagger : saqc.flagger.BaseFlagger
A saqc-flagger object.
"""
```
......
......@@ -264,11 +264,7 @@ def test_variableAssignments(data):
assert set(result_flags.columns) == set(data.columns) | {"dummy1", "dummy2"}
# TODO: why this must(!) fail ? - a comment would be helpful
@pytest.mark.xfail(strict=True)
def test_processMultiple(data_diff):
var1, var2, *_ = data_diff.columns
config = f"""
{F.VARNAME} ; {F.TEST}
dummy ; generic.process(func=var1 + 1)
......