MCPcopy Index your code
hub / github.com/python-pendulum/pendulum / average

Method average

src/pendulum/date.py:717–725  ·  view source on GitHub ↗

Modify the current instance to the average of a given instance (default now) and the current instance.

(self, dt: date | None = None)

Source from the content-addressed store, hash-verified

715 return self.set(self.year, dt.month, dt.day)
716
717 def average(self, dt: date | None = None) -> Self:
718 """
719 Modify the current instance to the average
720 of a given instance (default now) and the current instance.
721 """
722 if dt is None:
723 dt = Date.today()
724
725 return self.add(days=int(self.diff(dt, False).in_days() / 2))
726
727 # Native methods override
728

Callers 8

test_average_is_fluidFunction · 0.45
test_average_from_sameFunction · 0.45
test_average_from_lowerFunction · 0.45
test_average_is_fluidFunction · 0.45
test_average_from_sameFunction · 0.45
test_average_from_lowerFunction · 0.45

Calls 4

addMethod · 0.95
diffMethod · 0.95
todayMethod · 0.45
in_daysMethod · 0.45

Tested by 8

test_average_is_fluidFunction · 0.36
test_average_from_sameFunction · 0.36
test_average_from_lowerFunction · 0.36
test_average_is_fluidFunction · 0.36
test_average_from_sameFunction · 0.36
test_average_from_lowerFunction · 0.36