Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles committed Jun 19, 2024
1 parent a3c9925 commit 42b7e36
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions artistools/inputmodel/plotinitialcomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from pathlib import Path

import argcomplete
import matplotlib.cm as mplcm
import matplotlib.colors as mplcolors
import matplotlib.pyplot as plt
import matplotlibcm as mplcm
import matplotlibcolors as mplcolors
import numpy as np
import pandas as pd
from astropy import units as u
Expand Down
2 changes: 1 addition & 1 deletion artistools/lightcurve/plotlightcurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def plot_artis_lightcurve(
)
nts_last, validrange_start_days, validrange_end_days = None, -math.inf, math.inf

colorindex = None
colorindex: t.Any = None
for dirbin in dirbins:
lcdata = lcdataframes[dirbin]

Expand Down
8 changes: 6 additions & 2 deletions artistools/lightcurve/viewingangleanalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ def update_plotkwargs_for_viewingangle_colorbar(
angles = np.arange(0, at.get_viewingdirectionbincount())
colors = []
for angle in angles:
colorindex: t.Any
_, colorindex = at.lightcurve.plotlightcurve.get_viewinganglecolor_for_colorbar(
angle,
costheta_viewing_angle_bins,
Expand Down Expand Up @@ -630,7 +631,9 @@ def make_peak_colour_viewing_angle_plot(args):
print(f"All 100 angles are not in file {datafilename}. Quitting")
sys.exit(1)

second_band_brightness = second_band_brightness_at_peak_first_band(data, bands, modelpath, modelnumber, args)
second_band_brightness: t.Any = second_band_brightness_at_peak_first_band(
data, bands, modelpath, modelnumber, args
)

data[f"{bands[1]}at{bands[0]}max"] = second_band_brightness

Expand Down Expand Up @@ -725,6 +728,7 @@ def peakmag_risetime_declinerate_init(modelpaths, filternames_conversion_dict, a
modelname = at.get_model_name(modelpath)
modelnames.append(modelname) # save for later
print(f"Reading spectra: {modelname}")
lightcurve_data: t.Any
if args.filter:
lightcurve_data = at.lightcurve.generate_band_lightcurve_data(
modelpath, args, angle, modelnumber=modelnumber
Expand Down Expand Up @@ -794,7 +798,7 @@ def plot_viewanglebrightness_at_fixed_time(modelpath, args):

plotkwargs = {}

lcdataframes = at.lightcurve.readfile(modelpath / "light_curve_res.out")
lcdataframes: t.Any = at.lightcurve.readfile(modelpath / "light_curve_res.out")

timetoplot = at.match_closest_time(reftime=args.timedays, searchtimes=lcdataframes[0]["time"])
print(timetoplot)
Expand Down
5 changes: 3 additions & 2 deletions artistools/plottools.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def _set_formatted_label_text(self):
if stroffset:
stroffset = stroffset.replace(r"$\times", "$") + " "
strnewlabel = self.labeltemplate.format(stroffset)
assert self.axis is not None
self.axis.set_label_text(strnewlabel)
assert self.offset == 0
self.axis.offsetText.set_visible(False)
Expand Down Expand Up @@ -178,7 +179,7 @@ def autoscale(ax=None, axis="y", margin=0.1):
From https://stackoverflow.com/questions/29461608/matplotlib-fixing-x-axis-scale-and-autoscale-y-axis
"""

def calculate_new_limit(fixed, dependent, limit):
def calculate_new_limit(fixed, dependent, limit) -> tuple[float, float]:
"""Calculate the min/max of the dependent axis given a fixed axis with limits."""
if len(fixed) > 2:
mask = (fixed > limit[0]) & (fixed < limit[1]) & (~np.isnan(dependent)) & (~np.isnan(fixed))
Expand Down Expand Up @@ -211,7 +212,7 @@ def get_xy(artist):
ax = plt.gca()
newlow, newhigh = np.inf, -np.inf

for artist in ax.collections + ax.lines:
for artist in list(ax.collections) + list(ax.lines):
x, y = get_xy(artist)
if axis == "y":
setlim = ax.set_ylim
Expand Down
1 change: 1 addition & 0 deletions artistools/radfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def select_bin(radfielddata, nu=None, lambda_angstroms=None, modelgridindex=None
if lambda_angstroms is not None:
nu = 2.99792458e18 / lambda_angstroms
else:
assert nu is not None
lambda_angstroms = 2.99792458e18 / nu

dfselected = radfielddata.query(
Expand Down
2 changes: 1 addition & 1 deletion artistools/spectra/plotspectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pathlib import Path

import argcomplete
import matplotlib.artis as mplartist
import matplotlib.artist as mplartist
import matplotlib.axes as mplax
import matplotlib.figure as mplfig
import matplotlib.patches as mpatches
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ disallow_incomplete_defs = true
disallow_untyped_calls = true
disallow_untyped_defs = true
enable_error_code = [
#"possibly-undefined",
"possibly-undefined",
]

[[tool.mypy.overrides]]
Expand Down

0 comments on commit 42b7e36

Please sign in to comment.