import numpy as np
from dascore.core import get_coord
# Create a coordinate from a start, stop, and range value.
range_coord = get_coord(start=1, stop=12, step=1)
# Create an identical coordinate from an array.
array_coord = get_coord(data=np.arange(1, 12, 1))
# This array coord should return an identical coordinate
assert range_coord == array_coord
# Coordinate from an array that is sorted, but not evenly sampled
array = np.sort(np.random.rand(20))
array_coord2 = get_coord(data=array)
# Coordinate from random array
array = np.random.rand(20)
array_coord3 = get_coord(data=array)
# Create a partial coordinate of a given shape
partial_coord = get_coord(shape=(10,))get_coord
get_coord(
     data: ndarray | None | BaseCoord = None,
     values: ndarray | None = None,
     start = None,
     min = None,
     stop = None,
     max = None,
     step = None,
     units: None | pint.registry.Unit | pint.registry.Quantity | str[None, Unit, Quantity, str] = None,
     shape: None | int | tuple[None, int, tuple[int, …]] = None,
     dtype: str | numpy.dtype[str, dtype] = None,
 )-> ‘BaseCoord’
Return a coordinate from provided inputs.
This function figures out which kind of Coordinate should be returned for provided inputs.
Parameters
| Parameter | Description | 
|---|---|
| data | An array indicating the values or an integer to specify the length of a partial coordinate. | 
| values | Deprecated, use data instead. | 
| start | The start value of the array, inclusive. | 
| min | The minimum value, same as start. | 
| stop | The stopping value of an array, exclusive. | 
| step | The sampling spacing of an array. | 
| units | Indication of units. | 
| shape | If an int or tuple, the output should be a partial coord of with this shape. Otherwise, leave unset. | 
| dtype | Data type for coord. Often can be inferred from other arguments. | 
Note
The following combinations of input parameters are typical: (start, stop, step) (values) (values, step) - useful for length 1 arrays.
