dbldatagen.nrange module

This module defines the NRange class used to specify data ranges

class NRange(minValue=None, maxValue=None, step=None, until=None, **kwArgs)[source]

Bases: DataRange

Ranged numeric interval representing the interval minValue .. maxValue inclusive

A ranged object can be uses as an alternative to the minValue, maxValue, step parameters to the DataGenerator withColumn and withColumn objects. Specify by passing an instance of NRange to the dataRange parameter.

Parameters:
  • minValue – Minimum value of range. May be integer / long / float

  • maxValue – Maximum value of range. May be integer / long / float

  • step – Step value for range. May be integer / long / float

  • until – Upper bound for range ( i.e maxValue+1)

You may only specify a maxValue or until value not both.

For a decreasing sequence, use a negative step value.

adjustForColumnDatatype(ctype)[source]

Adjust default values for column output type

Parameters:

ctype – Spark SQL type instance to adjust range for

Returns:

No return value - executes for effect only

getContinuousRange()[source]

Convert range to continuous range

Returns:

float value for size of interval from minValue to maxValue

getDiscreteRange()[source]

Convert range to discrete range

Returns:

number of discrete values in range. For example NRange(1, 5, 0.5) has 8 discrete values

Note

A range of 0,4, 0.5 has 8 discrete values not 9 as the maxValue value is not part of the range

TODO: check range of values

getScale()[source]

Get scale of range

isEmpty()[source]

Check if object is empty (i.e all instance vars of note are None

Returns:

True if empty, False otherwise

isFullyPopulated()[source]

Check is all instance vars are populated

Returns:

True if fully populated, False otherwise