Python numpy.ma.make_mask() Examples
The following are 18
code examples of numpy.ma.make_mask().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy.ma
, or try the search function
.
Example #1
Source File: test_mrecords.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() assert_(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() assert_(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) assert_(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #2
Source File: test_mrecords.py From keras-lambda with MIT License | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() self.assertTrue(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() self.assertTrue(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) self.assertTrue(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #3
Source File: test_mrecords.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() assert_(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() assert_(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) assert_(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #4
Source File: test_mrecords.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() assert_(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() assert_(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) assert_(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #5
Source File: test_mrecords.py From coffeegrindsize with MIT License | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() assert_(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() assert_(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) assert_(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #6
Source File: test_mrecords.py From elasticintel with GNU General Public License v3.0 | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() self.assertTrue(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() self.assertTrue(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) self.assertTrue(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #7
Source File: test_mrecords.py From ImageFusion with MIT License | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() self.assertTrue(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() self.assertTrue(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) self.assertTrue(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #8
Source File: test_mrecords.py From mxnet-lambda with Apache License 2.0 | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() self.assertTrue(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() self.assertTrue(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) self.assertTrue(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #9
Source File: test_mrecords.py From pySINDy with MIT License | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() assert_(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() assert_(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) assert_(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #10
Source File: test_mrecords.py From recruit with Apache License 2.0 | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() assert_(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() assert_(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) assert_(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #11
Source File: test_mstats_extras.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def test_hdmedian(): # 1-D array x = ma.arange(11) assert_allclose(ms.hdmedian(x), 5, rtol=1e-14) x.mask = ma.make_mask(x) x.mask[:7] = False assert_allclose(ms.hdmedian(x), 3, rtol=1e-14) # Check that `var` keyword returns a value. TODO: check whether returned # value is actually correct. assert_(ms.hdmedian(x, var=True).size == 2) # 2-D array x2 = ma.arange(22).reshape((11, 2)) assert_allclose(ms.hdmedian(x2, axis=0), [10, 11]) x2.mask = ma.make_mask(x2) x2.mask[:7, :] = False assert_allclose(ms.hdmedian(x2, axis=0), [6, 7])
Example #12
Source File: test_mrecords.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() assert_(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() assert_(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) assert_(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #13
Source File: test_mrecords.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() assert_(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() assert_(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) assert_(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #14
Source File: test_mrecords.py From Computable with MIT License | 6 votes |
def test_hardmask(self): "Test hardmask" base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() self.assertTrue(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() self.assertTrue(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) self.assertTrue(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask) #
Example #15
Source File: test_mrecords.py From vnpy_crypto with MIT License | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() assert_(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() assert_(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) assert_(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #16
Source File: test_mrecords.py From auto-alt-text-lambda-api with MIT License | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() self.assertTrue(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() self.assertTrue(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) self.assertTrue(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #17
Source File: test_mrecords.py From lambda-packs with MIT License | 6 votes |
def test_hardmask(self): # Test hardmask base = self.base.copy() mbase = base.view(mrecarray) mbase.harden_mask() self.assertTrue(mbase._hardmask) mbase.mask = nomask assert_equal_records(mbase._mask, base._mask) mbase.soften_mask() self.assertTrue(not mbase._hardmask) mbase.mask = nomask # So, the mask of a field is no longer set to nomask... assert_equal_records(mbase._mask, ma.make_mask_none(base.shape, base.dtype)) self.assertTrue(ma.make_mask(mbase['b']._mask) is nomask) assert_equal(mbase['a']._mask, mbase['b']._mask)
Example #18
Source File: latin_sampler.py From CityEnergyAnalyst with MIT License | 4 votes |
def latin_sampler(locator, num_samples, variables): """ This script creates a matrix of m x n samples using the latin hypercube sampler. for this, it uses the database of probability distribtutions stored in locator.get_uncertainty_db() it returns clean and normalized samples. :param locator: pointer to locator of files of CEA :param num_samples: number of samples to do :param variables: list of variables to sample :return: 1. design: a matrix m x n with the samples where each feature is normalized from [0,1] 2. design_norm: a matrix m x n with the samples where each feature is normalized from [0,1] 3. pdf_list: a dataframe with properties of the probability density functions used in the exercise. """ # get probability density function PDF of variables of interest variable_groups = ('ENVELOPE', 'INDOOR_COMFORT', 'INTERNAL_LOADS','SYSTEMS') database = pd.concat([pd.read_excel(locator.get_uncertainty_db(), group, axis=1) for group in variable_groups]) pdf_list = database[database['name'].isin(variables)].set_index('name') # get number of variables num_vars = pdf_list.shape[0] # alternatively use len(variables) # get design of experiments samples = latin_hypercube.lhs(num_vars, samples=num_samples, criterion='maximin') for i, variable in enumerate(variables): distribution = pdf_list.loc[variable, 'distribution'] #sampling into lhs min = pdf_list.loc[variable, 'min'] max = pdf_list.loc[variable, 'max'] mu = pdf_list.loc[variable, 'mu'] stdv = pdf_list.loc[variable, 'stdv'] if distribution == 'triangular': loc = min scale = max - min c = (mu - min) / (max - min) samples[:, i] = triang(loc=loc, c=c, scale=scale).ppf(samples[:, i]) elif distribution == 'normal': samples[:, i] = norm(loc=mu, scale=stdv).ppf(samples[:, i]) elif distribution == 'boolean': # converts a uniform (0-1) into True/False samples[:, i] = ma.make_mask(np.rint(uniform(loc=min, scale=max).ppf(samples[:, i]))) else: # assume it is uniform samples[:, i] = uniform(loc=min, scale=max).ppf(samples[:, i]) min_max_scaler = preprocessing.MinMaxScaler(copy=True, feature_range=(0, 1)) samples_norm = min_max_scaler.fit_transform(samples) return samples, samples_norm, pdf_list