MCPcopy
hub / github.com/pydata/xarray / linspace

Method linspace

xarray/indexes/range_index.py:288–349  ·  view source on GitHub ↗

Create a new RangeIndex from given start / stop values and number of values. Parameters ---------- start : float Start of interval. The interval includes this value. stop : float, optional End of interval. The interval includes this va

(
        cls,
        start: float,
        stop: float,
        num: int = 50,
        endpoint: bool = True,
        *,
        coord_name: Hashable | None = None,
        dim: str,
        dtype: Any = None,
    )

Source from the content-addressed store, hash-verified

286
287 @classmethod
288 def linspace(
289 cls,
290 start: float,
291 stop: float,
292 num: int = 50,
293 endpoint: bool = True,
294 *,
295 coord_name: Hashable | None = None,
296 dim: str,
297 dtype: Any = None,
298 ) -> "RangeIndex":
299 """Create a new RangeIndex from given start / stop values and number of
300 values.
301
302 Parameters
303 ----------
304 start : float
305 Start of interval. The interval includes this value.
306 stop : float, optional
307 End of interval. The interval includes this value if ``endpoint=True``.
308 num : float, optional
309 Number of values in the interval, i.e., dimension size (default: 50).
310 endpoint : bool, optional
311 If True (default), the ``stop`` value is included in the interval.
312 coord_name : Hashable, optional
313 Name of the (lazy) coordinate variable that will be created and
314 associated with the new index. If ``None``, the coordinate is named
315 as the dimension name.
316 dim : str
317 Dimension name.
318 dtype : dtype, optional
319 The dtype of the coordinate variable (default: float64).
320
321 Examples
322 --------
323 >>> from xarray.indexes import RangeIndex
324
325 >>> index = RangeIndex.linspace(0.0, 1.0, 5, dim="x")
326 >>> ds = xr.Dataset(coords=xr.Coordinates.from_xindex(index))
327
328 >>> ds
329 <xarray.Dataset> Size: 40B
330 Dimensions: (x: 5)
331 Coordinates:
332 * x (x) float64 40B 0.0 0.25 0.5 0.75 1.0
333 Data variables:
334 *empty*
335 Indexes:
336 x RangeIndex (start=0, stop=1.25, step=0.25)
337
338 """
339 if coord_name is None:
340 coord_name = dim
341
342 if endpoint:
343 stop += (stop - start) / (num - 1)
344
345 transform = RangeCoordinateTransform(

Callers 15

make_dsMethod · 0.80
make_dsMethod · 0.80
make_datatreeMethod · 0.80
interp.pyFile · 0.80
setupMethod · 0.80
setupMethod · 0.80
setupMethod · 0.80
setupMethod · 0.80
scatter_example_datasetFunction · 0.80
_color_paletteFunction · 0.80
_determine_cmap_paramsFunction · 0.80

Calls 1

Tested by 15

easy_arrayFunction · 0.64
setUpMethod · 0.64
test_facetgrid_cmapMethod · 0.64
test_dotFunction · 0.64
test_dask_gradientFunction · 0.64