
    ht%                       S SK Jr  S SKrS SKJrJr  S SKJr  S SK	J
r
  S SKJr  S SKJr  \R                  " \5         S SKJr  SSS5        S SKJr  \(       a  S S	KJrJr  S S
KJrJrJrJrJr  \SSS.           SS jj5       r\SS.           SS jj5       r\SS.           SS jj5       r\" 5       SSS.           SS jj5       r\SSSS.             SS jj5       r\SSS.             SS jj5       r\SSS.             SS jj5       rSSSS.             SS jjrg! , (       d  f       GN= f)     )annotationsN)TYPE_CHECKINGoverload)	functions)parse_into_expression)unstable)	wrap_expr)Literal)ExprSeries)ClosedIntervalIntoExprIntoExprColumnNumericLiteralTemporalLiteral.)closedeagerc                   g N startendnum_samplesr   r   s        ]/home/james-whalen/.local/lib/python3.13/site-packages/polars/functions/range/linear_space.pylinear_spacer      s         )r   c                   g r   r   r   s        r   r   r   &   s     r   c                   g r   r   r   s        r   r   r   1   s     r   bothFc                   [        U 5      n[        U5      n[        U5      n[        [        R                  " XVXs5      5      nU(       a$  [        R
                  " U5      R                  5       $ U$ )uI
  
Create sequence of evenly-spaced points.

Parameters
----------
start
    Lower bound of the range.
end
    Upper bound of the range.
num_samples
    Number of samples in the output sequence.
closed : {'both', 'left', 'right', 'none'}
    Define which sides of the interval are closed (inclusive).
eager
    Evaluate immediately and return a `Series`.
    If set to `False` (default), return an expression instead.

.. warning::
    This functionality is experimental. It may be changed at any point without it
    being considered a breaking change.

Notes
-----
`linear_space` works with numeric and temporal dtypes. When the `start` and `end`
parameters are `Date` dtypes, the output sequence consists of equally-spaced
`Datetime` elements with millisecond precision.

Returns
-------
Expr or Series
    Column of data type `:class:Time`.

Examples
--------
>>> pl.linear_space(start=0, end=1, num_samples=3, eager=True)
shape: (3,)
Series: 'literal' [f64]
[
        0.0
        0.5
        1.0
]
>>> pl.linear_space(start=0, end=1, num_samples=3, closed="left", eager=True)
shape: (3,)
Series: 'literal' [f64]
[
        0.0
        0.333333
        0.666667
]
>>> pl.linear_space(start=0, end=1, num_samples=3, closed="right", eager=True)
shape: (3,)
Series: 'literal' [f64]
[
        0.333333
        0.666667
        1.0
]
>>> pl.linear_space(start=0, end=1, num_samples=3, closed="none", eager=True)
shape: (3,)
Series: 'literal' [f64]
[
        0.25
        0.5
        0.75
]
>>> from datetime import time
>>> pl.linear_space(
...     start=time(hour=1), end=time(hour=12), num_samples=3, eager=True
... )
shape: (3,)
Series: 'literal' [time]
[
        01:00:00
        06:30:00
        12:00:00
]

`Date` endpoints generate a sequence of `Datetime` values:

>>> from datetime import date
>>> pl.linear_space(
...     start=date(2025, 1, 1),
...     end=date(2025, 2, 1),
...     num_samples=3,
...     closed="right",
...     eager=True,
... )
shape: (3,)
Series: 'literal' [datetime[μs]]
[
        2025-01-11 08:00:00
        2025-01-21 16:00:00
        2025-02-01 00:00:00
]

When `eager=False` (default), an expression is produced. You can generate a sequence
using the length of the dataframe:

>>> df = pl.DataFrame({"a": [1, 2, 3, 4, 5]})
>>> df.with_columns(pl.linear_space(0, 1, pl.len()).alias("ls"))
shape: (5, 2)
┌─────┬──────┐
│ a   ┆ ls   │
│ --- ┆ ---  │
│ i64 ┆ f64  │
╞═════╪══════╡
│ 1   ┆ 0.0  │
│ 2   ┆ 0.25 │
│ 3   ┆ 0.5  │
│ 4   ┆ 0.75 │
│ 5   ┆ 1.0  │
└─────┴──────┘
)r   r	   plrr   Fselect	to_series)	r   r   r   r   r   start_pyexpr
end_pyexprnum_samples_pyexprresults	            r   r   r   <   sa    v )/L&s+J.{;3ENF xx))++Mr   )r   as_arrayr   c                   g r   r   r   r   r   r   r*   r   s         r   linear_spacesr-      s     r   )r   r*   c                   g r   r   r,   s         r   r-   r-      s     r   c                   g r   r   r,   s         r   r-   r-      s     r   c          	         [        U 5      n[        U5      n[        U5      n[        [        R                  " XgXU5      5      n	U(       a$  [        R
                  " U	5      R                  5       $ U	$ )u
  
Generate a sequence of evenly-spaced values for each row between `start` and `end`.

The number of values in each sequence is determined by `num_samples`.

Parameters
----------
start
    Lower bound of the range.
end
    Upper bound of the range.
num_samples
    Number of samples in the output sequence.
closed : {'both', 'left', 'right', 'none'}
    Define which sides of the interval are closed (inclusive).
as_array
    Return result as a fixed-length `Array`. `num_samples` must be a constant.
eager
    Evaluate immediately and return a `Series`.
    If set to `False` (default), return an expression instead.

.. warning::
    This functionality is experimental. It may be changed at any point without it
    being considered a breaking change.

Returns
-------
Expr or Series
    Column of data type `List(dtype)`.

See Also
--------
linear_space : Generate a single sequence of linearly-spaced values.

Examples
--------
>>> df = pl.DataFrame({"start": [1, -1], "end": [3, 2], "num_samples": [4, 5]})
>>> df.with_columns(ls=pl.linear_spaces("start", "end", "num_samples"))
shape: (2, 4)
┌───────┬─────┬─────────────┬────────────────────────┐
│ start ┆ end ┆ num_samples ┆ ls                     │
│ ---   ┆ --- ┆ ---         ┆ ---                    │
│ i64   ┆ i64 ┆ i64         ┆ list[f64]              │
╞═══════╪═════╪═════════════╪════════════════════════╡
│ 1     ┆ 3   ┆ 4           ┆ [1.0, 1.666667, … 3.0] │
│ -1    ┆ 2   ┆ 5           ┆ [-1.0, -0.25, … 2.0]   │
└───────┴─────┴─────────────┴────────────────────────┘
>>> df.with_columns(ls=pl.linear_spaces("start", "end", 3, as_array=True))
shape: (2, 4)
┌───────┬─────┬─────────────┬──────────────────┐
│ start ┆ end ┆ num_samples ┆ ls               │
│ ---   ┆ --- ┆ ---         ┆ ---              │
│ i64   ┆ i64 ┆ i64         ┆ array[f64, 3]    │
╞═══════╪═════╪═════════════╪══════════════════╡
│ 1     ┆ 3   ┆ 4           ┆ [1.0, 2.0, 3.0]  │
│ -1    ┆ 2   ┆ 5           ┆ [-1.0, 0.5, 2.0] │
└───────┴─────┴─────────────┴──────────────────┘
)r   r	   r"   r-   r#   r$   r%   )
r   r   r   r   r*   r   r&   r'   r(   r)   s
             r   r-   r-      sf    F )/L&s+J.{;&8(	
F xx))++Mr   )r   +NumericLiteral | TemporalLiteral | IntoExprr   r1   r   int | IntoExprr   r   r   Literal[False]returnr   )r   r1   r   r1   r   r2   r   r   r   Literal[True]r4   r   )r   r1   r   r1   r   r2   r   r   r   boolr4   Expr | Series)r   1NumericLiteral | TemporalLiteral | IntoExprColumnr   r8   r   int | IntoExprColumnr   r   r*   r6   r   r3   r4   r   )r   r8   r   r8   r   r9   r   r   r*   r6   r   r5   r4   r   )r   r8   r   r8   r   r9   r   r   r*   r6   r   r6   r4   r7   )
__future__r   
contextlibtypingr   r   polarsr   r#   polars._utils.parser   polars._utils.unstabler   polars._utils.wrapr	   suppressImportErrorpolars._plr_plrr"   r
   r   r   polars._typingr   r   r   r   r   r   r-   r   r   r   <module>rF      s   "  * ! 5 + (% & #  
 !6	4  
   
 
 
 !6	4  
    
 
 !6	4  
    
 
 $D6D	4D  D
 D D D DN 
 !<	: &
    
 
 
 !<	: &
     
 
 !<	: &
     
  $O<O	:O &O
 O O O O{ &%s   E
E