def compute_hiperspaces(self): # La característica heurística al buscar conexiones entre # diferentes clusters hace que pueda fallar # por lo que redirigimos la salida para ser silenciosos # en esos casos if not len(self.points) > 0: logger.error('No points to compute hull!') raise Exception('No points to compute hull!') stderr_fd = sys.stderr.fileno() with open('/tmp/qhull-output.log', 'w') as f, stderr_redirected(f): points = list(self.points) logger.info('Searching for hull in dimension %s based on %s points', len(points[0]),len(points)) output = qconvex('n',points) if len(output) == 1: logger.debug('Could not get Hull. Joggle input?') try: dim, facets_nbr, facets = self.__parse_hs_output(output) except IncorrectOutput: logger.warning('Could not get hull') raise CannotGetHull() logger.info('Found hull in dimension %s of %s facets', dim,len(facets)) self.dim = dim self.facets = facets if self.verbose: print "Computed MCH with ",facets_nbr," halfspaces" print 'This are them:\n' for facet in self.facets:print facet return self.dim
def compute_hiperspaces(self): if not len(self.points) > 0: logger.error('No points to compute hull!') raise Exception('No points to compute hull!') # The heuristic caracteristic when searching to connect # different clusters does that it might fail # so we redirect the stdout to avoid such error # being visible to user stderr_fd = sys.stderr.fileno() with open('/tmp/qhull-output.log', 'w') as f, stderr_redirected(f): points = list(self.points) logger.info('Searching for hull in dimension %s based on %s points', len(points[0]),len(points)) output = qconvex('n',points) if len(output) == 1: logger.debug('Could not get Hull. Joggle input?') try: dim, facets_nbr, facets = self.__parse_hs_output(output) except IncorrectOutput: logger.error('Could not get hull') raise CannotGetHull() logger.info('Found hull in dimension %s of %s facets', dim,facets_nbr) self.dim = dim self.facets = facets return self.dim