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 var
, std
, median
#3378
Add var
, std
, median
#3378
Conversation
86a8aa0
to
ead950e
Compare
src/scipp/core/data_group.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably update
scipp/tests/data_group_test.py
Lines 826 to 837 in 8e19ec9
reduction_ops = ( | |
'sum', | |
'mean', | |
'all', | |
'any', | |
'min', | |
'max', | |
'nansum', | |
'nanmean', | |
'nanmin', | |
'nanmax', | |
) |
} | ||
) | ||
if isinstance(x, DataGroup): | ||
return data_group_nary(sc_func, x, dim=dim, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why sc_func
and not _reduce_with_numpy
with the same args used above for dataset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's shorter. I could actually do the same for Dataset
. It has a tiny performance penalty put that shouldn't matter.
ddof: | ||
'Delta degrees of freedom'. | ||
For sample variances, set ``ddof=1`` to obtain an unbiased estimator. | ||
For normally distributed variables, set ``ddof=0`` to obtain a maximum | ||
likelihood estimate. | ||
See :func:`numpy.var` for more details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to add a comment (or even a specific error?) why this is required by Scipp? Otherwise we risk a future developer coming and changing this.
src/scipp/core/reduction.py
Outdated
This function computes the standard deviation of the input values which is *not* | ||
the related to the ``x.variances`` property but instead defined as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar.
src/scipp/core/reduction.py
Outdated
This function computes the standard deviation of the input values which is *not* | ||
the related to the ``x.variances`` property but instead defined as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar
# Yes, using identical with floats. | ||
# It works and allclose doesn't support datasets and data groups. | ||
sc.testing.assert_identical( | ||
sc.var(x, 'xx', ddof=0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to add separate tests to ensure that ddof
is required, to prevent changes by a future developer not aware of our intentions.
562ea74
to
92aad0d
Compare
Fixes #3357