Completed
Push — main ( a0025f...89fac6 )
by Jose Enrique
19s queued 16s
created

mutis.signal.Signal.gen_synth()   C

Complexity

Conditions 10

Size

Total Lines 19
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 16
nop 2
dl 0
loc 19
rs 5.9999
c 0
b 0
f 0

How to fix   Complexity   

Complexity

Complex classes like mutis.signal.Signal.gen_synth() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
# Licensed under a 3-clause BSD style license - see LICENSE
2
"""Synthetic generation of light curves."""
3
4
import logging
5
6
import matplotlib.pyplot as plt
0 ignored issues
show
introduced by
Unable to import 'matplotlib.pyplot'
Loading history...
7
import numpy as np
0 ignored issues
show
introduced by
Unable to import 'numpy'
Loading history...
8
import scipy.optimize as scipy_optimize
0 ignored issues
show
introduced by
Unable to import 'scipy.optimize'
Loading history...
9
import scipy.special as scipy_special
0 ignored issues
show
introduced by
Unable to import 'scipy.special'
Loading history...
10
import scipy.stats as scipy_stats
0 ignored issues
show
introduced by
Unable to import 'scipy.stats'
Loading history...
11
from matplotlib.offsetbox import AnchoredText
0 ignored issues
show
introduced by
Unable to import 'matplotlib.offsetbox'
Loading history...
12
13
from mutis.lib.signal import *
0 ignored issues
show
Coding Style introduced by
The usage of wildcard imports like mutis.lib.signal should generally be avoided.
Loading history...
Unused Code introduced by
log was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
nfft was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
scipy_signal was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
lc_gen_psd_c was imported with wildcard, but is not used.
Loading history...
14
15
__all__ = ["Signal"]
16
17
log = logging.getLogger(__name__)
18
19
20
21
class Signal:
22
    """Analysis and generation of a signal.
23
24
    Description goes here.
25
26
    Parameters
27
    ----------
28
    times : :class:`numpy.ndarray` or :class:`pandas.Series`
29
        Values of the time axis.
30
    values : :class:`numpy.ndarray` or :class:`pandas.Series`
31
        Values of the signal axis.
32
    fgen : :class:`str`
33
        Method used to generate the synthetic signal.
34
    """
35
36
    def __init__(self, times, values, fgen):
37
        self.times = np.array(times)
38
        self.values = np.array(values)
39
        self.fgen = fgen
40
        self.synth = None
41
42
        # TODO make attributes below specific of OU method / not the entire class
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
43
        self.theta = None
44
        self.mu = None
0 ignored issues
show
Coding Style Naming introduced by
Attribute name "mu" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
45
        self.sigma = None
46
47
    def gen_synth(self, samples):
48
        """Description goes here."""
49
50
        self.synth = np.empty((samples, self.times.size))
51
        for n in range(samples):
0 ignored issues
show
Coding Style Naming introduced by
Variable name "n" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
52
            if self.fgen == "lc_gen_samp":
53
                self.synth[n] = lc_gen_samp(self.values)
54
            elif self.fgen == "lc_gen_psd_nft":
55
                self.synth[n] = lc_gen_psd_nft(self.times, self.values)
56
            elif self.fgen == "lc_gen_psd_lombscargle":
57
                self.synth[n] = lc_gen_psd_lombscargle(self.times, self.values)
58
            elif self.fgen == "lc_gen_psd_fft":
59
                self.synth[n] = lc_gen_psd_fft(self.values)
60
            elif self.fgen == "lc_gen_ou":
61
                if self.theta is None or self.mu is None or self.sigma is None:
62
                    raise Exception("You need to set the parameters for the signal")
63
                self.synth[n] = lc_gen_ou(self.theta, self.mu, self.sigma, self.times)
64
            else:
65
                raise Exception(f"Unknown fgen method {self.fgen}")
66
67
    def OU_fit(self, bins=None, rang=None, a=1e-5, b=100):
0 ignored issues
show
Comprehensibility introduced by
This function exceeds the maximum number of variables (16/15).
Loading history...
Coding Style Naming introduced by
Method name "OU_fit" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Argument name "a" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Argument name "b" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
68
        """Description goes here."""
69
70
        # TODO: make a generic fit method
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
71
        res = dict()
72
73
        # estimate sigma
74
        try:
75
            # dy = np.diff(self.values)
76
            # dt = np.diff(self.times)
77
            sigma_est = (np.nanmean(np.diff(self.values) ** 2 / self.values[:-1] ** 2 / np.diff(self.times))) ** 0.5
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (116/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
78
            res["sigma_est"] = sigma_est
79
        except Exception as e:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "e" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
80
            raise Exception(f"Could not estimate sigma: {e}")
81
82
        # plot histogram
83
        if bins is None:
84
            bins = np.int(self.values.size ** 0.5 / 1.5)  # bins='auto'
85
        if rang is None:
86
            rang = (np.percentile(self.values, 0), np.percentile(self.values, 99))
87
        p, x = np.histogram(self.values, density=True, bins=bins, range=rang)  # bins='sqrt')
0 ignored issues
show
Coding Style Naming introduced by
Variable name "x" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "p" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
88
        x = (x + np.roll(x, -1))[:-1] / 2.0
0 ignored issues
show
Coding Style Naming introduced by
Variable name "x" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
89
90
        plt.subplots()
91
        plt.hist(self.values, density=True, alpha=0.75, bins=bins, range=rang)
92
        plt.plot(x, p, "r-", alpha=0.5)
93
        anchored_text = AnchoredText(
94
            f"mean    {np.mean(self.values):.2g} \n "
95
            "median  {np.median(self.values):.2g} \n "
96
            "mode    {scipy_stats.mode(self.values)[0][0]:.2g} \n "
97
            "std     {np.std(self.values):.2g} \n "
98
            "var     {np.var(self.values):.2g}",
99
            loc="upper right",
100
        )
101
        plt.gca().add_artist(anchored_text)
102
103
        # curve_fit
104
        try:
105
            popt, pcov = scipy_optimize.curve_fit(f=self.pdf, xdata=x, ydata=p)
106
            # print('curve_fit: (l, mu)')
107
            # print('popt: ')
108
            # print(popt)
109
            # print('pcov: ')
110
            # print(np.sqrt(np.diag(pcov)))
111
            x_c = np.linspace(1e-5, 1.1 * np.max(x), 1000)
112
            plt.plot(x_c, self.pdf(x_c, *popt), "k-", label="curve_fit", alpha=0.8)
113
            res["curve_fit"] = (popt, np.sqrt(np.diag(pcov)))
114
        except Exception as e:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "e" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
115
            raise Exception(f"Some error fitting with curve_fit {e}")
116
117
        # TODO: place outside as a helper class
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
118
        #       and understand how it is used
119
        #       is it mu really needed ?
120
        #       mu here is different than self.mu
121
        # fit pdf with MLE
122
        class OU(scipy_stats.rv_continuous):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
123
            def _pdf(self, x, l, mu):
0 ignored issues
show
Coding Style Naming introduced by
Argument name "x" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Argument name "l" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
Coding Style Naming introduced by
Argument name "mu" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
124
                return (l * mu) ** (1 + l) / scipy_special.gamma(1 + l) * np.exp(-l * mu / x) / x ** (l + 2)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (108/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
125
126
        try:
127
            fit = OU(a=a, b=np.percentile(self.values, b)).fit(self.values, 1, 1, floc=0, fscale=1)
128
            # print('MLE fit: (l, mu)')
129
            # print(fit)
130
            x_c = np.linspace(0, 1.1 * np.max(x), 1000)
131
            plt.plot(x_c, self.pdf(x_c, fit[0], fit[1]), "k-.", label="MLE", alpha=0.8)
132
            res["MLE_fit"] = fit[:-2]
133
        except Exception as e:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "e" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
134
            raise Exception(f"Some error fitting with MLE {e}")
135
        plt.legend(loc="lower right")
136
        plt.show()
137
138
        # estimate theta
139
        res["th_est1"] = fit[0] * sigma_est ** 2 / 2
140
        res["th_est2"] = popt[0] * sigma_est ** 2 / 2
141
142
        return res
143
144
    def OU_check_gen(self, theta, mu, sigma):
0 ignored issues
show
Coding Style Naming introduced by
Argument name "mu" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Method name "OU_check_gen" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
145
        """Description goes here."""
146
147
        # TODO: make a generic check_gen method
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
148
149
        t, y = self.times, self.values
0 ignored issues
show
Coding Style Naming introduced by
Variable name "y" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Variable name "t" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
150
        y2 = lc_gen_ou(theta, mu, sigma, self.times, scale=np.std(self.values), loc=np.mean(self.values))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (105/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style Naming introduced by
Variable name "y2" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
151
152
        # plot the two signals
153
        fig, ax = plt.subplots()
0 ignored issues
show
Unused Code introduced by
The variable fig seems to be unused.
Loading history...
Coding Style Naming introduced by
Variable name "ax" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
154
        ax.plot(t, y, "b-", label="orig", lw=0.5, alpha=0.8)
155
        ax2 = ax.twinx()
156
        ax2.plot(t, y2, "r-", label="gen", lw=0.5, alpha=0.8)
157
        plt.show()
158
159
        # plot their histogram
160
        fig, ax = plt.subplots()
0 ignored issues
show
Coding Style Naming introduced by
Variable name "ax" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
161
        bins = "auto"  # bins = np.int(y.size**0.5/1.5) #
162
        rang = (np.percentile(y, 0), np.percentile(y, 99))
163
        ax.hist(y, density=True, color="b", alpha=0.4, bins=bins, range=rang)
164
        ax2 = ax.twinx()
165
        bins = "auto"  # bins = np.int(y.size**0.5/1.5) #
166
        rang = (np.percentile(y2, 0), np.percentile(y2, 99))
167
        ax2.hist(y2, density=True, color="r", alpha=0.4, bins=bins, range=rang)
168
        plt.show()
169
170
        # plot their PSD
171
        fig, ax = plt.subplots()
0 ignored issues
show
Coding Style Naming introduced by
Variable name "ax" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
172
        ax.psd(y, color="b", lw=1, alpha=0.5)
173
        ax2 = ax.twinx()
174
        ax2.psd(y2, color="r", lw=1, alpha=0.5)
175
        plt.show()
176
177
    def PSD_check_gen(self, fgen=None, ax=None):
0 ignored issues
show
Coding Style Naming introduced by
Argument name "ax" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Method name "PSD_check_gen" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
178
        """Description goes here."""
179
180
        # TODO: make a generic check_gen method
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
181
182
        if fgen is None:
183
            fgen = self.fgen
184
        if ax is None:
185
            ax = plt.gca()
186
187
        if fgen == "lc_gen_psd_nft":
188
            s2 = lc_gen_psd_nft(self.times, self.values)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "s2" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
189
        elif fgen == "lc_gen_psd_lombscargle":
190
            s2 = lc_gen_psd_lombscargle(self.times, self.values)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "s2" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
191
        elif fgen == "lc_gen_psd_fft":
192
            s2 = lc_gen_psd_fft(self.values)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "s2" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
193
        else:
194
            raise Exception("No valid fgen specified")
195
196
        ax.plot(self.times, self.values, "b-", label="orig", lw=0.5, alpha=0.8)
197
        ax.plot(self.times, s2, "r-", label="gen", lw=0.5, alpha=0.8)
198
        ax.legend()
199
200
    @staticmethod
201
    def pdf(xx, ll, mu):
0 ignored issues
show
Coding Style Naming introduced by
Argument name "ll" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Argument name "xx" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style Naming introduced by
Argument name "mu" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
202
        """Fit pdf as a curve."""
203
        return (ll * mu) ** (1 + ll) / scipy_special.gamma(1 + ll) * np.exp(-ll * mu / xx) / xx ** (ll + 2)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (107/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
204