Points.copy¶
- Points.copy(toCopy=None, start=None, end=None, number=None, randomize=False, features=None, *, useLog=None)¶
Copy certain points of this object.
A variety of methods for specifying the points to copy based on the provided parameters. If
toCopy
is not None,start
andend
must be None. Ifstart
orend
is not None,toCopy
must be None.The
nimble.match
module contains many helpful functions that could be used fortoCopy
.- Parameters:
toCopy (identifier, list of identifiers, function, query) –
identifier - a name or index
list of identifiers - an iterable container of identifiers
function - accepts a point as its only argument and returns a boolean value to indicate if the point should be copied. See
nimble.match
for common functions.query - string in the format ‘FEATURENAME OPERATOR VALUE’ (i.e “ft1 < 10”, “id4 == yes”, or “col4 is nonZero”) where OPERATOR is separated from the FEATURENAME and VALUE by whitespace characters. See
nimble.match.QueryString
for string requirements.
start (identifier) – Parameters indicating range based copying. Begin the copying at the location of
start
. Finish copying at the inclusiveend
location. If only one of start and end are non-None, the other default to 0 and the number of values in each point, respectively.end (identifier) – Parameters indicating range based copying. Begin the copying at the location of
start
. Finish copying at the inclusiveend
location. If only one of start and end are non-None, the other default to 0 and the number of values in each point, respectively.number (int) – The quantity of points that are to be copied, the default None means unrestricted copying. This can be provided on its own (toCopy, start and end are None) to the first
number
of points, or in conjuction with toCopy or start and end, to limit their output.randomize (bool) – Indicates whether random sampling is to be used in conjunction with the number parameter. If randomize is False, the chosen points are determined by point order, otherwise it is uniform random across the space of possible points.
features (None, identifier, list of identifiers) – Only apply the target function to a selection of features in each point. May be a single feature name or index, an iterable, container of feature names and/or indices. None indicates application to all features.
useLog (bool, None) – Local control for whether to send object creation to the logger. If None (default), use the value as specified in the “logger” “enabledByDefault” configuration option. If True, send to the logger regardless of the global option. If False, do NOT send to the logger, regardless of the global option.
- Returns:
nimble Base object
See also
Examples
>>> lst = [[0, 0, 0, 0], ... [1, 1, 1, 1], ... [2, 2, 2, 2], ... [3, 3, 3, 3]] >>> X = nimble.data(lst, featureNames=['a', 'b', 'c', 'd'], ... pointNames=['0', '1', '2', '3']) >>> single = X.points.copy('1') >>> single <Matrix 1pt x 4ft a b c d ┌─────────── 1 │ 1 1 1 1 > >>> multiple = X.points.copy(['1', 3]) >>> multiple <Matrix 2pt x 4ft a b c d ┌─────────── 1 │ 1 1 1 1 3 │ 3 3 3 3 > >>> func = X.points.copy(nimble.match.allZero) >>> func <Matrix 1pt x 4ft a b c d ┌─────────── 0 │ 0 0 0 0 > >>> strFunc = X.points.copy("a >= 2") >>> strFunc <Matrix 2pt x 4ft a b c d ┌─────────── 2 │ 2 2 2 2 3 │ 3 3 3 3 > >>> startEnd = X.points.copy(start=1, end=2) >>> startEnd <Matrix 2pt x 4ft a b c d ┌─────────── 1 │ 1 1 1 1 2 │ 2 2 2 2 > >>> numberNoRandom = X.points.copy(number=2) >>> numberNoRandom <Matrix 2pt x 4ft a b c d ┌─────────── 0 │ 0 0 0 0 1 │ 1 1 1 1 > >>> nimble.random.setSeed(42) >>> numberRandom = X.points.copy(number=2, randomize=True) >>> numberRandom <Matrix 2pt x 4ft a b c d ┌─────────── 0 │ 0 0 0 0 3 │ 3 3 3 3 >
Keywords: duplicate, replicate, clone, filter