| 93 | array (array-like): input data |
| 94 | """ |
| 95 | def __new__(cls, array): |
| 96 | if "linux" not in sys.platform: |
| 97 | raise EnvironmentError("SharedNDArray only works on Linux") |
| 98 | |
| 99 | array = np.asarray(array) |
| 100 | file = tempfile.NamedTemporaryFile() |
| 101 | self = super(SharedNDArray, cls).__new__(cls, file, dtype=array.dtype, shape=array.shape) |
| 102 | # keep reference to the tmp file, otherwise it will be released |
| 103 | self.file = file |
| 104 | self[:] = array |
| 105 | return self |
| 106 | |
| 107 | @classmethod |
| 108 | def from_memmap(cls, *args, **kwargs): |