|
1 | | -# Copyright 2022 MathWorks, Inc. |
| 1 | +# Copyright 2014-2015 MathWorks, Inc. |
| 2 | +""" |
| 3 | +Array interface between Python and MATLAB. |
2 | 4 |
|
3 | | -import os |
4 | | -import platform |
5 | | -import sys |
6 | | -import pkgutil |
7 | | - |
8 | | -__path__ = pkgutil.extend_path(__path__, __name__) |
9 | | -package_folder = os.path.dirname(os.path.realpath(__file__)) |
10 | | -sys.path.append(package_folder) |
11 | | - |
12 | | -def add_dirs_to_path(bin_dir, engine_dir, extern_dir): |
13 | | - """ |
14 | | - Adds MATLAB engine and extern/bin directories to sys.path. |
15 | | - """ |
16 | | - path = 'PATH' |
17 | | - |
18 | | - if not os.path.isdir(engine_dir): |
19 | | - raise RuntimeError("Could not find directory: {0}".format(engine_dir)) |
20 | | - |
21 | | - if not os.path.isdir(extern_dir): |
22 | | - raise RuntimeError("Could not find directory: {0}".format(extern_dir)) |
23 | | - |
24 | | - if platform.system() == 'Windows': |
25 | | - if not os.path.isdir(bin_dir): |
26 | | - raise RuntimeError("Could not find directory: {0}".format(bin_dir)) |
27 | | - if path in os.environ: |
28 | | - paths = os.environ[path] |
29 | | - os.environ[path] = bin_dir + os.pathsep + paths |
30 | | - else: |
31 | | - os.environ[path] = bin_dir |
32 | | - if sys.version_info.major >= 3 and sys.version_info.minor >= 8: |
33 | | - os.add_dll_directory(bin_dir) |
| 5 | +This package defines classes and exceptions that create and manage |
| 6 | +multidimensional arrays in Python that are passed between Python and MATLAB. |
| 7 | +The arrays, while similar to Python sequences, have different behaviors. |
34 | 8 |
|
35 | | - sys.path.insert(0, engine_dir) |
36 | | - sys.path.insert(0, extern_dir) |
37 | | - |
38 | | -arch_file = os.path.join(package_folder, 'engine', '_arch.txt') |
39 | | -if not os.path.isfile(arch_file): |
40 | | - raise RuntimeError("The MATLAB Engine for Python install is corrupted, please try to re-install.") |
41 | | - |
42 | | -with open(arch_file, 'r') as root: |
43 | | - [arch, bin_folder, engine_folder, extern_bin] = [line.strip() for line in root.readlines()] |
| 9 | +Modules |
| 10 | +------- |
| 11 | + * mlarray - type-specific multidimensional array classes for working |
| 12 | + with MATLAB |
| 13 | + * mlexceptions - exceptions raised manipulating mlarray objects |
| 14 | +""" |
44 | 15 |
|
| 16 | +import os |
| 17 | +import sys |
| 18 | +from pkgutil import extend_path |
| 19 | +__path__ = extend_path(__path__, '__name__') |
45 | 20 |
|
46 | | -add_dirs_to_path(bin_folder, engine_folder, extern_bin) |
| 21 | +_package_folder = os.path.dirname(os.path.realpath(__file__)) |
| 22 | +sys.path.append(_package_folder) |
47 | 23 |
|
48 | | -from matlabmultidimarrayforpython import double, single, uint8, int8, uint16, \ |
49 | | - int16, uint32, int32, uint64, int64, logical, ShapeError, SizeError |
| 24 | +from mlarray import double, single, uint8, int8, uint16, \ |
| 25 | + int16, uint32, int32, uint64, int64, logical |
| 26 | +from mlexceptions import ShapeError as ShapeError |
| 27 | +from mlexceptions import SizeError as SizeError |
0 commit comments