Skip to content

Commit

Permalink
fix pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
parkma99 committed Mar 9, 2022
1 parent 608af2a commit 212fd2b
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions stingray/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from astropy.time import TimeDelta
import numpy.typing as npt
TTime = Union[Time, TimeDelta, Quantity, npt.ArrayLike]
Tso = TypeVar("Tso", bound = "StingrayObject")
Tso=TypeVar("Tso", bound = "StingrayObject")


class StingrayObject(object):
Expand Down Expand Up @@ -142,11 +142,11 @@ def from_astropy_table(cls: Type[Tso], ts: Table) -> Tso:
array_attrs = ts.colnames

# Set the main attribute first
mainarray = np.array(ts[cls.main_array_attr]) # type: ignore
setattr(cls, cls.main_array_attr, mainarray) # type: ignore
mainarray = np.array(ts[cls.main_array_attr]) # type: ignore
setattr(cls, cls.main_array_attr, mainarray) # type: ignore

for attr in array_attrs:
if attr == cls.main_array_attr: # type: ignore
if attr == cls.main_array_attr: # type: ignore
continue
setattr(cls, attr.lower(), np.array(ts[attr]))

Expand Down Expand Up @@ -192,18 +192,18 @@ def from_xarray(cls: Type[Tso], ts: Dataset) -> Tso:
"""
cls = cls()

if len(ts[cls.main_array_attr]) == 0: # type: ignore
if len(ts[cls.main_array_attr]) == 0: # type: ignore
# return an empty object
return cls

array_attrs = ts.coords

# Set the main attribute first
mainarray = np.array(ts[cls.main_array_attr]) # type: ignore
setattr(cls, cls.main_array_attr, mainarray) # type: ignore
mainarray = np.array(ts[cls.main_array_attr]) # type: ignore
setattr(cls, cls.main_array_attr, mainarray) # type: ignore

for attr in array_attrs:
if attr == cls.main_array_attr: # type: ignore
if attr == cls.main_array_attr: # type: ignore
continue
setattr(cls, attr, np.array(ts[attr]))

Expand Down Expand Up @@ -258,11 +258,11 @@ def from_pandas(cls: Type[Tso], ts: DataFrame) -> Tso:
array_attrs = ts.columns

# Set the main attribute first
mainarray = np.array(ts[cls.main_array_attr]) # type: ignore
setattr(cls, cls.main_array_attr, mainarray) # type: ignore
mainarray = np.array(ts[cls.main_array_attr]) # type: ignore
setattr(cls, cls.main_array_attr, mainarray) # type: ignore

for attr in array_attrs:
if attr == cls.main_array_attr: # type: ignore
if attr == cls.main_array_attr: # type: ignore
continue
setattr(cls, attr, np.array(ts[attr]))

Expand Down Expand Up @@ -445,8 +445,8 @@ def to_astropy_timeseries(self) -> TimeSeries:
if data == {}:
data = None

if self.time is not None and np.size(self.time) > 0: # type: ignore
times = TimeDelta(self.time * u.s) # type: ignore
if self.time is not None and np.size(self.time) > 0: # type: ignore
times = TimeDelta(self.time * u.s) # type: ignore
ts = TimeSeries(data=data, time=times)
else:
ts = TimeSeries()
Expand Down Expand Up @@ -485,7 +485,7 @@ def from_astropy_timeseries(cls, ts: TimeSeries) -> StingrayTimeseries:
mjdref = ts.meta["mjdref"]

time, mjdref = interpret_times(time, mjdref)
cls.time = np.asarray(time) # type: ignore
cls.time = np.asarray(time) # type: ignore

array_attrs = ts.colnames
for key, val in ts.meta.items():
Expand Down Expand Up @@ -514,10 +514,10 @@ def change_mjdref(self, new_mjdref: float) -> StingrayTimeseries:
new_lc : :class:`StingrayTimeseries` object
The new time series, shifted by MJDREF
"""
time_shift = (self.mjdref - new_mjdref) * 86400 # type: ignore
time_shift = (self.mjdref - new_mjdref) * 86400 # type: ignore

ts = self.shift(time_shift)
ts.mjdref = new_mjdref # type: ignore
ts.mjdref = new_mjdref # type: ignore
return ts

def shift(self, time_shift: float) -> StingrayTimeseries:
Expand All @@ -536,9 +536,9 @@ def shift(self, time_shift: float) -> StingrayTimeseries:
"""
ts = copy.deepcopy(self)
ts.time = np.asarray(ts.time) + time_shift # type: ignore
ts.time = np.asarray(ts.time) + time_shift # type: ignore
if hasattr(ts, "gti"):
ts.gti = np.asarray(ts.gti) + time_shift # type: ignore
ts.gti = np.asarray(ts.gti) + time_shift # type: ignore

return ts

Expand Down

0 comments on commit 212fd2b

Please sign in to comment.