Skip to content

Commit a3e59a7

Browse files
committed
to_screen
1 parent 252e7f6 commit a3e59a7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/actinet/accPlot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def main(): # noqa: C901
8080
if len(sys.argv) < 2:
8181
msg = "\nInvalid input, please enter at least 1 parameter, e.g."
8282
msg += "\npython accPlot.py timeSeries.csv.gz \n"
83-
utils.toScreen(msg)
83+
utils.to_screen(msg)
8484
parser.print_help()
8585
sys.exit(-1)
8686
args = parser.parse_args()

src/actinet/utils/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
from typing import Union
88

99

10-
def infer_freq(x):
10+
def infer_freq(t):
1111
"""Like pd.infer_freq but more forgiving"""
12-
freq, _ = stats.mode(np.diff(x), keepdims=False)
12+
tdiff = t.to_series().diff()
13+
q1, q3 = tdiff.quantile([0.25, 0.75])
14+
tdiff = tdiff[(q1 <= tdiff) & (tdiff <= q3)]
15+
freq = tdiff.mean()
1316
freq = pd.Timedelta(freq)
1417
return freq
1518

1619

17-
def toScreen(msg, verbose=True):
20+
def to_screen(msg, verbose=True):
1821
"""
1922
Print msg str prepended with current time
2023

0 commit comments

Comments
 (0)