mindscience.data.HyperCube
- class mindscience.data.HyperCube(name, dim, coord_min, coord_max, dtype=numpy.float32, sampling_config=None)[source]
Definition of HyperCube object.
- Parameters
name (str) – Name of the hyper cube.
dim (int) – Number of dimensions.
coord_min (Union[int, float, tuple, list, numpy.ndarray]) – Minimal coordinate of the hyper cube. If the parameter type is tuple or list, each element should be of type int or float, and its length must be consistent with the dim parameter.
coord_max (Union[int, float, tuple, list, numpy.ndarray]) – Maximal coordinate of the hyper cube. If the parameter type is tuple or list, each element should be of type int or float, and its length must be consistent with the dim parameter.
dtype (numpy.dtype) – Data type of sampled point data type. Default:
numpy.float32.sampling_config (SamplingConfig) – Sampling configuration. Default:
None.
- Raises
TypeError – sampling_config is not instance of class SamplingConfig.
Examples
>>> from mindscience.data import generate_sampling_config, HyperCube >>> hypercube_random = dict({ ... 'domain': dict({ ... 'random_sampling': True, ... 'size': 1000, ... 'sampler': 'uniform' ... }), ... 'BC': dict({ ... 'random_sampling': True, ... 'size': 200, ... 'sampler': 'uniform', ... 'with_normal': False, ... }), ... }) >>> sampling_config = generate_sampling_config(hypercube_random) >>> hypercube = HyperCube("HyperCube", 3, [-1, 2, 1], [0, 3, 2], sampling_config=sampling_config) >>> domain = hypercube.sampling(geom_type="domain") >>> bc = hypercube.sampling(geom_type="BC") >>> print(domain.shape) (1000, 3)
- sampling(geom_type='domain')[source]
Sampling points.
- Parameters
geom_type (str) –
Geometry type: can be
'domain'or'BC'. Default:'domain'.'domain', feasible domain of the problem.'BC', boundary of the problem.
- Returns
- Numpy.ndarray, if the with_normal property of boundary configuration is true, returns 2D numpy array with
boundary normal vectors. Otherwise, returns 2D numpy array without boundary normal vectors.
- Raises
KeyError – If geom_type is
'domain'butself.sampling_config.domainisNone.KeyError – If geom_type is
'BC'butself.sampling_config.bcisNone.ValueError – If geom_type is neither
'BC'nor'domain'.