File convex_hull.py changed (mode: 100644) (index a83cd27..d5911fd) |
... |
... |
class QHull: |
430 |
430 |
def regen(self): |
def regen(self): |
431 |
431 |
points = getattr(self.sample, self.space) |
points = getattr(self.sample, self.space) |
432 |
432 |
self.convex_hull = spatial.ConvexHull(points, incremental=self.incremental) |
self.convex_hull = spatial.ConvexHull(points, incremental=self.incremental) |
433 |
|
|
|
434 |
|
def enough_points(self): return self.sample.nvar < self.sample.nsim |
|
435 |
433 |
|
|
436 |
434 |
|
|
437 |
435 |
def __getattr__(self, attr): |
def __getattr__(self, attr): |
|
... |
... |
class QHull: |
443 |
441 |
#č a ihned ji vrátit |
#č a ihned ji vrátit |
444 |
442 |
self.regen() |
self.regen() |
445 |
443 |
return self.convex_hull |
return self.convex_hull |
|
444 |
|
|
|
445 |
|
elif attr == 'enough_points': |
|
446 |
|
return self.sample.nvar < self.sample.nsim |
446 |
447 |
|
|
447 |
448 |
elif attr == 'A': |
elif attr == 'A': |
448 |
449 |
return self.convex_hull.equations[:,:-1] |
return self.convex_hull.equations[:,:-1] |
|
... |
... |
class QHull: |
450 |
451 |
return self.convex_hull.equations[:,-1] |
return self.convex_hull.equations[:,-1] |
451 |
452 |
|
|
452 |
453 |
elif attr == 'points': |
elif attr == 'points': |
453 |
|
if self.enough_points(): |
|
|
454 |
|
if self.enough_points: |
454 |
455 |
return self.convex_hull.points |
return self.convex_hull.points |
455 |
456 |
else: |
else: |
456 |
457 |
return getattr(self.sample, self.space) |
return getattr(self.sample, self.space) |
457 |
458 |
|
|
458 |
459 |
elif attr == 'npoints': |
elif attr == 'npoints': |
459 |
|
if self.enough_points(): |
|
|
460 |
|
if self.enough_points: |
460 |
461 |
return self.convex_hull.npoints |
return self.convex_hull.npoints |
461 |
462 |
else: |
else: |
462 |
463 |
return len(self.sample) |
return len(self.sample) |
463 |
464 |
|
|
464 |
465 |
elif attr == 'nsimplex': |
elif attr == 'nsimplex': |
465 |
|
if self.enough_points(): |
|
|
466 |
|
if self.enough_points: |
466 |
467 |
return self.convex_hull.nsimplex |
return self.convex_hull.nsimplex |
467 |
468 |
else: |
else: |
468 |
469 |
return 0 |
return 0 |
|
... |
... |
class QHull: |
488 |
489 |
|
|
489 |
490 |
|
|
490 |
491 |
def is_inside(self, nodes): |
def is_inside(self, nodes): |
491 |
|
if self.enough_points(): |
|
|
492 |
|
if self.enough_points: |
492 |
493 |
self._update() |
self._update() |
493 |
494 |
x = getattr(nodes, self.space) |
x = getattr(nodes, self.space) |
494 |
495 |
|
|
|
... |
... |
class QHull: |
516 |
517 |
# valid only if space==G |
# valid only if space==G |
517 |
518 |
def get_r(hull): |
def get_r(hull): |
518 |
519 |
if hull.space=='G': |
if hull.space=='G': |
519 |
|
if hull.enough_points(): |
|
|
520 |
|
if hull.enough_points: |
520 |
521 |
hull._update() |
hull._update() |
521 |
522 |
b = hull.convex_hull.equations[:,-1] |
b = hull.convex_hull.equations[:,-1] |
522 |
523 |
return -np.nanmax(b) |
return -np.nanmax(b) |