From 04c951da2d173c106c2a76c5aaeb1fe4b8202be6 Mon Sep 17 00:00:00 2001 From: otieno-juma Date: Mon, 17 Jun 2024 10:45:08 -0500 Subject: [PATCH] DOC: AI generated examples for ma.left_shift. I used AI Llama 3 to help create these. @bmwoodruff and I reviewed them. [skip azp] [skip cirrus] --- numpy/ma/core.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 04f6b434b731..c4dae547202d 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -7337,6 +7337,33 @@ def left_shift(a, n): -------- numpy.left_shift + Examples + -------- + Shift with a masked array: + + >>> arr = np.ma.array([10, 20, 30], mask=[False, True, False]) + >>> np.ma.left_shift(arr, 1) + masked_array(data=[20, --, 60], + mask=[False, True, False], + fill_value=999999) + + Large shift: + + >>> np.ma.left_shift(10, 10) + masked_array(data=10240, + mask=False, + fill_value=999999) + + Shift with a scalar and an array: + + >>> scalar = 10 + >>> arr = np.ma.array([1, 2, 3], mask=[False, True, False]) + >>> np.ma.left_shift(scalar, arr) + masked_array(data=[20, --, 80], + mask=[False, True, False], + fill_value=999999) + + """ m = getmask(a) if m is nomask: