naobservatory / p2ra

4 stars 1 forks source link

Changed logic of hatch_zero_counts. #236

Closed simonleandergrimm closed 9 months ago

simonleandergrimm commented 10 months ago

Previously, when hatch_zero_counts was set to False, the code would add hatching. I reversed the logic to hatch when set to True.

simonleandergrimm commented 10 months ago

@dp-rice Mypy is failing on a part of the code that I haven't edited. Do you know why that is? Will look into it myself if you don't know.

OK
Running mypy to check types...
plot_summaries.py:169: error: Argument 1 to "set_xlim" of "_AxesBase" has
incompatible type "list[int]"; expected "float | tuple[float, float] | None" 
[arg-type]
        ax.set_xlim([-13, -3])
                    ^~~~~~~~~
plot_summaries.py:180: error: Item "Artist" of "Artist | None" has no attribute
"set_edgecolor"  [union-attr]
            legend_handle.set_edgecolor(legend_handle.get_facecolor())
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plot_summaries.py:180: error: Item "None" of "Artist | None" has no attribute
"set_edgecolor"  [union-attr]
            legend_handle.set_edgecolor(legend_handle.get_facecolor())
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plot_summaries.py:180: error: Item "Artist" of "Artist | None" has no attribute
"get_facecolor"  [union-attr]
            legend_handle.set_edgecolor(legend_handle.get_facecolor())
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plot_summaries.py:180: error: Item "None" of "Artist | None" has no attribute
"get_facecolor"  [union-attr]
            legend_handle.set_edgecolor(legend_handle.get_facecolor())
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plot_summaries.py:210: error: Argument 1 to "set_xlim" of "_AxesBase" has
incompatible type "list[int]"; expected "float | tuple[float, float] | None" 
[arg-type]
        ax.set_xlim([-15, -7])
                    ^~~~~~~~~
plot_summaries.py:243: error: Item "Artist" of "Artist | None" has no attribute
"set_edgecolor"  [union-attr]
            legend_handle.set_edgecolor(legend_handle.get_facecolor())
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plot_summaries.py:243: error: Item "None" of "Artist | None" has no attribute
"set_edgecolor"  [union-attr]
            legend_handle.set_edgecolor(legend_handle.get_facecolor())
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plot_summaries.py:243: error: Item "Artist" of "Artist | None" has no attribute
"get_facecolor"  [union-attr]
            legend_handle.set_edgecolor(legend_handle.get_facecolor())
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plot_summaries.py:243: error: Item "None" of "Artist | None" has no attribute
"get_facecolor"  [union-attr]
            legend_handle.set_edgecolor(legend_handle.get_facecolor())
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 10 errors in 1 file (checked 35 source files)
FAIL: types
Error: Process completed with exit code 1.
dp-rice commented 10 months ago

Code looks fine. Good catch.

dp-rice commented 10 months ago

As for mypy, @simonleandergrimm was it failing when you ran it locally? Seems like probably a version issue. One of the errors can be fixed by changing a list to a Tuple. The other you might need to tell mypy to ignore. You may also just want to tell mypy not to check types on matplotlib at all. The typing for that package isn't very good, I don't think.

simonleandergrimm commented 9 months ago

Ready to go in when you can quiet mypy

Fixed the mypy issue by incorporating the changes made in #237