|  | 
| 8 | 8 | import numpy as np | 
| 9 | 9 | from matplotlib import pyplot as plt | 
| 10 | 10 | from matplotlib.axes import Axes  # for type hints only | 
|  | 11 | +from pathlib import Path | 
|  | 12 | + | 
| 11 | 13 | 
 | 
| 12 | 14 | # https://docs.astropy.org/en/stable/api/astropy.stats.bayesian_blocks.html | 
| 13 |  | -from lightcurves.HopFinder import * | 
|  | 15 | +import lightcurves.HopFinder as hf | 
| 14 | 16 | 
 | 
| 15 | 17 | logging.basicConfig(level=logging.ERROR) | 
| 16 | 18 | """ | 
|  | 
| 23 | 25 | """ | 
| 24 | 26 | 
 | 
| 25 | 27 | 
 | 
| 26 |  | -def load_lc(path: str) -> LightCurve: | 
|  | 28 | +def load_lc(path: str | Path) -> LightCurve: | 
| 27 | 29 |     """ | 
| 28 | 30 |     Load a pickled LightCurve instance from a file created with `save_lc()`. | 
| 29 | 31 | 
 | 
| 30 | 32 |     WARNING | 
| 31 | 33 |     ------- | 
| 32 | 34 |     Uses pickle. Loaded instance reflects the class at save-time. | 
| 33 | 35 |     """ | 
| 34 |  | -    with open(path, "rb") as f: | 
|  | 36 | +    path = Path(path) | 
|  | 37 | +    with path.open("rb") as f: | 
| 35 | 38 |         return pickle.load(f) | 
| 36 | 39 | 
 | 
| 37 |  | - | 
| 38 |  | -def load_lc_npy(path: str) -> LightCurve: | 
|  | 40 | +'''  | 
|  | 41 | +this following is exactly like the previous one.. might not be necessary | 
|  | 42 | +def load_lc_npy(path: str | Path) -> LightCurve: | 
| 39 | 43 |     """ | 
| 40 | 44 |     Load pickled LightCurve instance from numpy array created with `save_lc()`. | 
| 41 | 45 | 
 | 
| 42 | 46 |     WARNING | 
| 43 | 47 |     ------- | 
| 44 | 48 |     Uses pickle. Loaded instance reflects the class at save-time. | 
| 45 | 49 |     """ | 
| 46 |  | -    with open(path, "rb") as f: | 
|  | 50 | +    path = Path(path) | 
|  | 51 | +    with path.open("rb") as f: | 
| 47 | 52 |         return pickle.load(f) | 
| 48 |  | - | 
|  | 53 | +''' | 
| 49 | 54 | 
 | 
| 50 | 55 | def load_lc_csv(path: str) -> LightCurve: | 
| 51 | 56 |     """ | 
| @@ -89,7 +94,7 @@ def flux_puffer( | 
| 89 | 94 |         Associated uncertainties, modified analogously. | 
| 90 | 95 |     """ | 
| 91 | 96 |     flux_new = np.where(flux > threshold, flux, threshold) | 
| 92 |  | -    flux_error_new = np.where(flux > threshold, flux_error, th_error) | 
|  | 97 | +    flux_error_new = np.where(flux > threshold, flux_error, threshold_error) | 
| 93 | 98 |     return (flux_new, flux_error_new) | 
| 94 | 99 | 
 | 
| 95 | 100 | 
 | 
| @@ -979,13 +984,13 @@ def find_hop( | 
| 979 | 984 |                 self.baseline = np.mean(self.flux) | 
| 980 | 985 |             else: | 
| 981 | 986 |                 self.baseline = baseline | 
| 982 |  | -            hopfinder = HopFinderBaseline(lc_edges) | 
|  | 987 | +            hopfinder = hf.HopFinderBaseline(lc_edges) | 
| 983 | 988 |         if method == "half": | 
| 984 |  | -            hopfinder = HopFinderHalf(lc_edges) | 
|  | 989 | +            hopfinder = hf.HopFinderHalf(lc_edges) | 
| 985 | 990 |         if method == "sharp": | 
| 986 |  | -            hopfinder = HopFinderSharp(lc_edges) | 
|  | 991 | +            hopfinder = hf.HopFinderSharp(lc_edges) | 
| 987 | 992 |         if method == "flip": | 
| 988 |  | -            hopfinder = HopFinderFlip(lc_edges) | 
|  | 993 | +            hopfinder = hf.HopFinderFlip(lc_edges) | 
| 989 | 994 |         self.hops = hopfinder.find(self) | 
| 990 | 995 |         return self.hops | 
| 991 | 996 | 
 | 
|  | 
0 commit comments