This is an automated email from the ASF dual-hosted git repository.
nchung pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-nexus.git
The following commit(s) were added to refs/heads/master by this push:
new 0c23469 SDAP-406: Fix comparison stats bug in timeseriesspark
algorithm (#209)
0c23469 is described below
commit 0c23469e4d5ccd093f722807af3b32eb03c33d06
Author: Kevin <[email protected]>
AuthorDate: Tue Oct 18 09:47:45 2022 -0700
SDAP-406: Fix comparison stats bug in timeseriesspark algorithm (#209)
* Comparison stats returns empty dictionary if linear regression results
contains nans
* Updated changelog with SDAP-406 bug fix
---
CHANGELOG.md | 1 +
.../webservice/algorithms_spark/TimeSeriesSpark.py | 18 +++++++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e023343..f8306cd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -51,6 +51,7 @@ and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0
- Fixed certificate error in Dockerfile
- SDAP-403: Remote timeout fix and HofMoeller bug fix
- Fixed matchup insitu query loading on import; loads when needed instead
+- SDAP-406: Fixed `/timeSeriesSpark`comparison stats bug
### Security
diff --git a/analysis/webservice/algorithms_spark/TimeSeriesSpark.py
b/analysis/webservice/algorithms_spark/TimeSeriesSpark.py
index 0287592..faeaa0b 100644
--- a/analysis/webservice/algorithms_spark/TimeSeriesSpark.py
+++ b/analysis/webservice/algorithms_spark/TimeSeriesSpark.py
@@ -317,13 +317,17 @@ class TimeSeriesSparkHandlerImpl(NexusCalcSparkHandler):
xy[item[1]["ds"]].append(item[1]["mean"])
slope, intercept, r_value, p_value, std_err = stats.linregress(xy[0],
xy[1])
- comparisonStats = {
- "slope": slope,
- "intercept": intercept,
- "r": r_value,
- "p": p_value,
- "err": std_err
- }
+
+ if any(np.isnan([slope, intercept, r_value, p_value, std_err])):
+ comparisonStats = {}
+ else:
+ comparisonStats = {
+ "slope": slope,
+ "intercept": intercept,
+ "r": r_value,
+ "p": p_value,
+ "err": std_err
+ }
return comparisonStats