Skip to content

nmoehring/FRange

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FRange

A float-range class that handles unions and intersections. Created primarily to track the domains of functions.

Argument Form

Arguments for init, union, and intersect are in the form of iterables of iterables, which is how ranges are stored internally, and look like this:
>>> rg = FRange([ [1,2,'(]'], [3,4,'[)'] ])
but you can also input ranges in interval notation in a string, like this:
>>> rg.union(["(1,2]", "[3,4)"])
The brackets work the way they do in interval notation, () not including the edge values, and [] including the edge values.

Methods

The value() method returns the range in a string, with discontinuous ranges being combined with a union character:
"(1,2]∪[3,4)"
The union() and intersect() methods work like the mathematical union and intersect operators. Union (∪) combines two separate intervals, and intersect (∩) yields the interval at the intersection of two intervals:
>>> rg1, rg2 = [FRange("(2,3)")] * 2
>>> rg1.union("(4,5]")
>>> rg2.intersect("[2.4,4)")
>>> rg1.value()
"(2,3)∪(4,5]"
>>> rg2.value()
"[2.4,3)"
The class also has a rand() method which returns a random number within the object's range, and will eventually have a generator, as well.

About

Float Range for tracking domains of functions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages