How to use the laspy.base.FakeMmap function in laspy

To help you get started, we’ve selected a few laspy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github laspy / laspy / laspy / base.py View on Github external
def map(self):
        '''Memory map the file'''
        if self.fileref == False and not self.compressed:
            raise laspy.util.LaspyException("File not opened.")
        if self.mode in ("r", "r-"):

            if self.compressed and self.mode != "r-" and not HAVE_LAZPERF:
                 self._mmap = FakeMmap(self.filename)
            else:
                self._mmap = mmap.mmap(self.fileref.fileno(), 0, access = mmap.ACCESS_READ)
        elif self.mode in ("w", "rw"):
            self._mmap = mmap.mmap(self.fileref.fileno(), 0, access = mmap.ACCESS_WRITE)
        else:
            raise laspy.util.LaspyException("Invalid Mode: " + str(self.mode))
github laspy / laspy / laspy / base.py View on Github external
def _prepare_np_frombuffer_data(data):
    # convert data according to `numpy` changes:
    # https://github.com/numpy/numpy/blob/a9bb517554004cf2ce7a4be93bcbfb63ee149844/doc/source/release/1.17.0-notes.rst#do-not-lookup-__buffer__-attribute-in-numpyfrombuffer
    change_data = isinstance(data, FakeMmap) and \
        LooseVersion(np.version.version) >= LooseVersion('1.17.0')
    return data.view if change_data else data