MCPcopy
hub / github.com/ResidentMario/missingno / squarify

Function squarify

missingno/missingno.py:731–748  ·  view source on GitHub ↗
(_min_x, _max_x, _min_y, _max_y, df)

Source from the content-addressed store, hash-verified

729 # Recursive quadtree. This subroutine, when, builds a dictionary of squares, stored by tuples keyed with
730 # (min_x, max_x, min_y, max_y), whose values are the nullity of squares containing less than 100 observations.
731 def squarify(_min_x, _max_x, _min_y, _max_y, df):
732 arr = df[[x_col, y_col]].values
733 points_inside = df[(_min_x < arr[:,0]) &
734 (arr[:,0] < _max_x) &
735 (_min_y < arr[:,1]) &
736 (arr[:,1] < _max_y)]
737 if len(points_inside) < cutoff:
738 # The following subroutine groups `geo_group` by `x_col` and `y_col`, and calculates and returns
739 # a list of points in the group (`points`) as well as its overall nullity (`geographic_nullity`). The
740 # first of these calculations is ignored.
741 _, square_nullity = _calculate_geographic_nullity(points_inside, x_col, y_col)
742 rectangles.append(((_min_x, _max_x,_min_y, _max_y), square_nullity))
743 else:
744 _mid_x, _mid_y = (_min_x + _max_x) / 2, (_min_y + _max_y) / 2
745 squarify(_min_x, _mid_x, _mid_y, _max_y, points_inside)
746 squarify(_min_x, _mid_x, _min_y, _mid_y, points_inside)
747 squarify(_mid_x, _max_x, _mid_y, _max_y, points_inside)
748 squarify(_mid_x, _max_x, _min_y, _mid_y, points_inside)
749
750 # Populate the `squares` array, per the above.
751 squarify(min_x, max_x, min_y, max_y, df)

Callers 1

geoplotFunction · 0.85

Calls 1

Tested by

no test coverage detected