hawc_hal.convenience_functions.fit_point_source   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 43
dl 0
loc 73
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B fit_point_source() 0 67 5
1
from ..HAL import HAL
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
from threeML import DataList, JointLikelihood
0 ignored issues
show
introduced by
third party import "from threeML import DataList, JointLikelihood" should be placed before "from ..HAL import HAL"
Loading history...
4
5
6
def fit_point_source(roi,
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
best-practice introduced by
Too many arguments (9/5)
Loading history...
Comprehensibility introduced by
This function exceeds the maximum number of variables (19/15).
Loading history...
7
                     maptree,
8
                     response,
9
                     point_source_model,
10
                     bin_list,
11
                     confidence_intervals=False,
12
                     liff=False,
13
                     pixel_size=0.17,
14
                     verbose=False):
15
16
    data_radius = roi.data_radius.to("deg").value
17
18
    if not liff:
19
20
        # This is a 3ML plugin
21
        hawc = HAL("HAWC",
22
                   maptree,
23
                   response,
24
                   roi,
25
                   flat_sky_pixels_size=pixel_size)
26
27
        hawc.set_active_measurements(bin_list=bin_list)
28
29
    else:
30
31
        from threeML import HAWCLike
0 ignored issues
show
Bug introduced by
The name HAWCLike does not seem to exist in module threeML.
Loading history...
32
33
        hawc = HAWCLike("HAWC",
34
                        maptree,
35
                        response,
36
                        fullsky=True)
37
38
        hawc.set_bin_list(bin_list)
39
40
        ra_roi, dec_roi = roi.ra_dec_center
41
42
        hawc.set_ROI(ra_roi, dec_roi, data_radius)
43
44
    if not liff:
45
46
        hawc.display()
47
48
    data = DataList(hawc)
49
50
    jl = JointLikelihood(point_source_model, data, verbose=verbose)
0 ignored issues
show
Coding Style Naming introduced by
Variable name "jl" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]2,30)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' 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...
51
52
    point_source_model.display(complete=True)
53
54
    try:
55
56
        jl.set_minimizer("minuit")
57
58
    except:
0 ignored issues
show
Coding Style Best Practice introduced by
General except handlers without types should be used sparingly.

Typically, you would use general except handlers when you intend to specifically handle all types of errors, f.e. when logging. Otherwise, such general error handlers can mask errors in your application that you want to know of.

Loading history...
59
60
        jl.set_minimizer("minuit")
61
62
    param_df, like_df = jl.fit()
63
64
    if confidence_intervals:
65
66
        ci = jl.get_errors()
0 ignored issues
show
Coding Style Naming introduced by
Variable name "ci" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]2,30)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' 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...
67
68
    else:
69
70
        ci = None
0 ignored issues
show
Coding Style Naming introduced by
Variable name "ci" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]2,30)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' 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...
71
72
    return param_df, like_df, ci, jl.results
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...