diff --git a/artistools/inputmodel/plotinitialcomposition.py b/artistools/inputmodel/plotinitialcomposition.py index beb5a3bf2..6032aadc1 100755 --- a/artistools/inputmodel/plotinitialcomposition.py +++ b/artistools/inputmodel/plotinitialcomposition.py @@ -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 diff --git a/artistools/lightcurve/plotlightcurve.py b/artistools/lightcurve/plotlightcurve.py index 869d954ea..bc060f758 100644 --- a/artistools/lightcurve/plotlightcurve.py +++ b/artistools/lightcurve/plotlightcurve.py @@ -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] diff --git a/artistools/lightcurve/viewingangleanalysis.py b/artistools/lightcurve/viewingangleanalysis.py index 923eeaf52..c6e9b6c00 100644 --- a/artistools/lightcurve/viewingangleanalysis.py +++ b/artistools/lightcurve/viewingangleanalysis.py @@ -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, @@ -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 @@ -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 @@ -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) diff --git a/artistools/plottools.py b/artistools/plottools.py index 3b26c2448..187e23aa4 100644 --- a/artistools/plottools.py +++ b/artistools/plottools.py @@ -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) @@ -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)) @@ -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 diff --git a/artistools/radfield.py b/artistools/radfield.py index 37cdff581..d4e0cdb9a 100755 --- a/artistools/radfield.py +++ b/artistools/radfield.py @@ -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( diff --git a/artistools/spectra/plotspectra.py b/artistools/spectra/plotspectra.py index 5a733c442..bc30c6f3f 100755 --- a/artistools/spectra/plotspectra.py +++ b/artistools/spectra/plotspectra.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index c9996562a..13e2b244e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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]]