Coverage for ana/single.py : 71%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# SPDX-FileCopyrightText: 2020 Jonathan Pieper <jpieper@stud.uni-frankfurt.de>
2#
3# SPDX-License-Identifier: GPL-3.0-or-later
5"""
6SingleMeasurement
7=================
9Main parent class for all single measurements.
10These Measurements are represent by one DataFrame.
11"""
13from .measurement import MeasurementClass
15import pandas as pd
16import scipy.stats
19class SingleM(MeasurementClass):
20 def __init__(self):
21 """The main constructor for all single measurements."""
22 super().__init__()
23 self.data = pd.DataFrame()
25 linear_regression = lambda self, x, y: scipy.stats.linregress(x, y)
27 def fit_variable(self, df, x, y):
28 """Applys a linear regression and adds result to DataFrame
30 Args:
31 df (pd.DataFrame): Fit data
32 x (np.ndarray): Fit variable.
33 y (np.ndarray): Fit variable.
34 """
35 fit = self.linear_regression(x[1], y[1])
36 for var in [x, y]:
37 df[var[0]] = var[1]
39 return df