Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python use negation with maskedarray

import numpy
data = numpy.array([[ 1, 2, 5 ]])
mask = numpy.array([[0,1,0]])

numpy.ma.masked_array(data, ~mask) 
# note this probably won't work right for non-boolean (T/F) values

# or
numpy.ma.masked_array(data, numpy.logical_not(mask))


# for example

>>> a = numpy.array([False,True,False])
>>> ~a
array([ True, False,  True], dtype=bool)
>>> numpy.logical_not(a)
array([ True, False,  True], dtype=bool)
>>> a = numpy.array([0,1,0])
>>> ~a
array([-1, -2, -1])
>>> numpy.logical_not(a)
array([ True, False,  True], dtype=bool)


Comment

PREVIOUS NEXT
Code Example
Python :: string replace in python 
Python :: python yield from 
Python :: how to get the memory location of a varible in python 
Python :: command to install python3.6 on mac os 
Python :: reverse a string or number in python 
Python :: powershell bulk rename and add extra string to filename 
Python :: how to check for updates from github in python 
Python :: stripping whitespace in python 
Python :: stores number in set using input in python 
Python :: search whole drive for a file in python 
Python :: pandas csv sum column 
Python :: how to use histogram in python 
Python :: plot the distribution of value_counts() python 
Python :: how to use with statementin python 2.4 
Python :: a star search algorithm python code 
Python :: remove items from list while iterating python 
Python :: encoding character or string to integer in python 
Python :: filter function in python 
Python :: get image image memeory size in url inpyton requests 
Python :: 151 - Power Crisis solution in python 
Python :: python toupper 
Python :: python slicing a list 
Python :: how to find the no of user for a wifi using python for ubuntu 
Python :: cannot create group in read-only mode. keras 
Python :: pytorch torchaudio torchvision cu113 
Python :: connect to vvenv python 
Python :: speech to text 
Python :: come fare aprire una pagina web python 
Python :: python replace in string 
Python :: Query a PSQL Database From Python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =