General#

Functions#

pyscan.general.d_range.drange(start, delta, stop)#

Returns an array from start, with steps of size delta to stop, inclusive.

  • If stop-start is not divisible by delta, it fits as many integer steps of delta as possible, then adds stop as the final step.

  • If stop-start < delta returns [start, stop].

  • If stop == start returns [start].

Parameters:
startfloat or int

Start value.

deltafloat or int

Distance between points.

stopfloat or int

Last value.

Returns:
numpy.ndarray
pyscan.general.first_string.first_string(obj)#

Returns either the first string in a list of strings or a string if the object is a single string type. Parameters ———- obj : str, list or array

Instance of string or array of strings.

Returns#

  • obj if obj is a string

  • obj[0] if obj is an array

pyscan.general.is_list_type.is_list_type(obj)#

Determines if input is a list, np.ndarray, or tuple.

Parameters:
obj

Object of any type.

Returns:
bool

True if obj is of list type.

pyscan.general.is_numeric_type.is_numeric_type(obj)#

Determines if input is an int or float. Parameters ———- obj :

Object of any type.

Returns#

bool

True if obj is an int or float.

pyscan.general.same_length.same_length(list_of_lists)#

Function that determines if lists have the same length

Parameters:
list_of_listslist[list] or dict

a list or dict of lists

Returns:
bool

True if lists have the same length

pyscan.general.set_difference.set_difference(list1, list2)#

Fuction that returns a list containing unique items in list1 which are not in list2.

Parameters:
  • list1 – list or object

  • list2 – list or object

Returns:

list of unique items in list1 which are not found in list2

pyscan.general.append_stack_or_contact.append_stack_or_contact(array, value)#

Appends a new value to an array`depending on the shape of the `array.

If array is empty, returns value If array is the same size as the value, stacks the value If the array is larger than the value, concatenates the value

Parameters:
arrayarray like object
valueint, float, or list like object
Returns:
np.ndarray