numpy — 0.5.0

org.pycforge.numpy · Author: PyCForge

License: GPL-3.0-only · Created: 2026-10-31

Runtime conversion · Direct declared calls

Function index

absolute · add · argmax · argmin · array · concatenate · copy · divide · full · max · mean · min · multiply · negative · ones · sqrt · subtract · sum · true_divide · zeros

Overview

A bounded NumPy conversion package for one-dimensional finite float64 arrays.

Using this import

Select Runtime and declare *import numpy as np. Use np.array(values, dtype="float64"). Read results with indexing or tolist(); copy with np.copy(a) or a.copy().

Author's limitations

One-dimensional contiguous finite float64 arrays only; no dtype inference, views, slicing, array broadcasting or external buffers. Assignment and argument passing share the same array; constructors, copy and arithmetic allocate independent storage. Integer indexing (including negatives), finite numeric item assignment, len, iteration/reversed, copy()/tolist() and shape/size/ndim are supported. Nonfinite inputs and arithmetic overflow are explicitly outside this profile; NumPy warning/seterr policies are not implemented. Allocation and work share the Runtime context budgets. Budget exhaustion is fatal; ordinary type, shape and bounds errors are catchable. Returned arrays stay valid within their originating context until destruction or explicit collection without a live root. Runtime only; no Python/NumPy runtime or arbitrary native dependencies in generated C. Extrema min/max require nonempty arrays and reject mixed-sign zero extrema; argmin/argmax keep the first tie. Unary negative/absolute/sqrt return independent arrays; negative square roots are refused. Concatenate joins a nonempty list/tuple of arrays, including empty constituents, with axis=None, 0 or -1. Divide/true_divide and / require an array and equal array lengths; zero divisors raise ValueError and nonfinite results raise OverflowError. In-place /= retains identity and all aliases; failure preserves every element. Empty division performs no element operations. Profile 0.5 adds sum and mean module functions, returning independent float64 scalars without array allocation or mutation. Both accept a and axis positionally or by name; axis is None, integer 0 or -1. No sequence coercion, dtype, out, keepdims, initial or where. Sum splits each range at floor(length/2), evaluates the left half then the right, and rounds each addition to binary64, nearest ties-to-even. Mean divides that sum by the exact element count (at most 2**53). Empty sum is +0.0; empty mean raises ValueError. Any nonfinite intermediate sum raises OverflowError, including for mean and later-cancelling inputs. A different rounding mode raises RuntimeError. A zero total is normalized to +0.0; mean division may underflow to signed zero. Gradual underflow is required. The addition depth is ceil(log2(n)); cancellation can cause large relative error. NumPy may use a different reduction tree: bitwise agreement is not promised. For n>0, u=2**-53, eta=2**-1074, h=ceil(log2(n)), A=sum(abs(exact input)), gamma(k)=k*u/(1-k*u): absolute sum error is bounded by gamma(h)*A+(n-1)*eta*(1+gamma(h)); mean error by gamma(h+1)*A/n+2*eta*(1+gamma(h+1)). These bounds assume nearest rounding, gradual underflow and no intermediate overflow. Work exhaustion stays fatal; input storage is preserved on every failure. Array printing/formatting, comparisons, dtype objects, NumPy scalar object identity and warning/seterr behavior are unsupported. Arithmetic overflow is refused explicitly; sum/mean have documented rounding bounds and may differ from NumPy.

Release notes

Adds fixed pairwise sum and mean through profile 0.5; finite intermediate sums and nearest rounding are required. Reference fixtures generated with NumPy 2.3.5.

Examples are author-supplied fixture snapshots. The SDK reports verification for its recorded environment; PyCForge registration does not rerun them.

Conversion contract

Use *import numpy in the module preamble. Each signature states accepted positions, names and defaults. A slash marks positional-only parameters; a star marks keyword-only parameters. Argument expansion, function values and Typed conversion are unsupported.

One-dimensional contiguous finite float64 arrays only; no dtype inference, views, slicing, array broadcasting or external buffers. Assignment and argument passing share the same array; constructors, copy and arithmetic allocate independent storage. Integer indexing (including negatives), finite numeric item assignment, len, iteration/reversed, copy()/tolist() and shape/size/ndim are supported. Nonfinite inputs and arithmetic overflow are explicitly outside this profile; NumPy warning/seterr policies are not implemented. Allocation and work share the Runtime context budgets. Budget exhaustion is fatal; ordinary type, shape and bounds errors are catchable. Returned arrays stay valid within their originating context until destruction or explicit collection without a live root. Runtime only; no Python/NumPy runtime or arbitrary native dependencies in generated C. Extrema min/max require nonempty arrays and reject mixed-sign zero extrema; argmin/argmax keep the first tie. Unary negative/absolute/sqrt return independent arrays; negative square roots are refused. Concatenate joins a nonempty list/tuple of arrays, including empty constituents, with axis=None, 0 or -1. Divide/true_divide and / require an array and equal array lengths; zero divisors raise ValueError and nonfinite results raise OverflowError. In-place /= retains identity and all aliases; failure preserves every element. Empty division performs no element operations. Profile 0.5 adds sum and mean module functions, returning independent float64 scalars without array allocation or mutation. Both accept a and axis positionally or by name; axis is None, integer 0 or -1. No sequence coercion, dtype, out, keepdims, initial or where. Sum splits each range at floor(length/2), evaluates the left half then the right, and rounds each addition to binary64, nearest ties-to-even. Mean divides that sum by the exact element count (at most 2**53). Empty sum is +0.0; empty mean raises ValueError. Any nonfinite intermediate sum raises OverflowError, including for mean and later-cancelling inputs. A different rounding mode raises RuntimeError. A zero total is normalized to +0.0; mean division may underflow to signed zero. Gradual underflow is required. The addition depth is ceil(log2(n)); cancellation can cause large relative error. NumPy may use a different reduction tree: bitwise agreement is not promised. For n>0, u=2**-53, eta=2**-1074, h=ceil(log2(n)), A=sum(abs(exact input)), gamma(k)=k*u/(1-k*u): absolute sum error is bounded by gamma(h)*A+(n-1)*eta*(1+gamma(h)); mean error by gamma(h+1)*A/n+2*eta*(1+gamma(h+1)). These bounds assume nearest rounding, gradual underflow and no intermediate overflow. Work exhaustion stays fatal; input storage is preserved on every failure.

numpy.absolute(x, /) -> array1d-float64

Return each element's absolute value in independent storage; negative zero becomes positive zero.

x: positional-only; required

Return each element's absolute value in independent storage; negative zero becomes positive zero.

Return each element's absolute value in independent storage; negative zero becomes positive zero.

Argument 1: x: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: elementwise

numpy.add(x1, x2, /) -> array1d-float64

Add two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

x1: positional-only; required

x2: positional-only; required

Add two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

Add two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: arithmetic

numpy.argmax(a, axis=None) -> int64

Return the int64 index of the first maximum in a nonempty supported array. Equal values, including signed zeros, keep the first index. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Return the int64 index of the first maximum in a nonempty supported array. Equal values, including signed zeros, keep the first index.

Result must fit signed int64; nonfinite or out-of-range results raise an exception.

Return the int64 index of the first maximum in a nonempty supported array. Equal values, including signed zeros, keep the first index. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

Argument 1: a: A supported finite float64 array; mean and extrema require at least one element, while sum accepts an empty array.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: An independent int64 scalar; the input array is unchanged.

View example: reductions

numpy.argmin(a, axis=None) -> int64

Return the int64 index of the first minimum in a nonempty supported array. Equal values, including signed zeros, keep the first index. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Return the int64 index of the first minimum in a nonempty supported array. Equal values, including signed zeros, keep the first index.

Result must fit signed int64; nonfinite or out-of-range results raise an exception.

Return the int64 index of the first minimum in a nonempty supported array. Equal values, including signed zeros, keep the first index. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

Argument 1: a: A supported finite float64 array; mean and extrema require at least one element, while sum accepts an empty array.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: An independent int64 scalar; the input array is unchanged.

View example: reductions

numpy.array(object, dtype) -> array1d-float64

Copy a flat numeric list, tuple or supported array into new float64 storage. Explicit dtype='float64' is required; no dtype inference.

object: positional-or-keyword; required

dtype: positional-or-keyword; required

Copy a flat numeric list, tuple or supported array into new float64 storage. Explicit dtype='float64' is required; no dtype inference.

Copy a flat numeric list, tuple or supported array into new float64 storage. Explicit dtype='float64' is required; no dtype inference.

Argument 1: object: See the fixed operation signature and contract.

Argument 2: dtype: Float64 string; required unless the signature supplies its default.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: constructors

numpy.concatenate(arrays, /, axis=0) -> array1d-float64

Join a nonempty list or tuple of supported arrays into independent storage. Empty constituent arrays are allowed. axis accepts None, 0 or -1; no out, dtype or casting overrides.

arrays: positional-only; required

axis: positional-or-keyword; default 0

Join a nonempty list or tuple of supported arrays into independent storage. Empty constituent arrays are allowed. axis accepts None, 0 or -1; no out, dtype or casting overrides.

Join a nonempty list or tuple of supported arrays into independent storage. Empty constituent arrays are allowed. axis accepts None, 0 or -1; no out, dtype or casting overrides.

Argument 1: arrays: See the fixed operation signature and contract.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: concatenation

numpy.copy(a) -> array1d-float64

Copy a supported array into independent writable storage. Assignment alone shares the original array.

a: positional-or-keyword; required

Copy a supported array into independent writable storage. Assignment alone shares the original array.

Copy a supported array into independent writable storage. Assignment alone shares the original array.

Argument 1: a: A supported finite float64 array; mean and extrema require at least one element, while sum accepts an empty array.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: independent-copies

numpy.divide(x1, x2, /) -> array1d-float64

Divide two equal-length float64 arrays, or an array and a numeric scalar, into independent storage. A zero divisor or nonfinite result is outside the finite profile and raises an exception.

x1: positional-only; required

x2: positional-only; required

Divide two equal-length float64 arrays, or an array and a numeric scalar, into independent storage. A zero divisor or nonfinite result is outside the finite profile and raises an exception.

Divide two equal-length float64 arrays, or an array and a numeric scalar, into independent storage. A zero divisor or nonfinite result is outside the finite profile and raises an exception.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: elementwise

numpy.full(shape, fill_value, dtype) -> array1d-float64

Create a one-dimensional array filled with one numeric value. Explicit dtype='float64' is required.

shape: positional-or-keyword; required

fill_value: positional-or-keyword; required

dtype: positional-or-keyword; required

Create a one-dimensional array filled with one numeric value. Explicit dtype='float64' is required.

Create a one-dimensional array filled with one numeric value. Explicit dtype='float64' is required.

Argument 1: shape: See the fixed operation signature and contract.

Argument 2: fill_value: See the fixed operation signature and contract.

Argument 3: dtype: Float64 string; required unless the signature supplies its default.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: constructors

numpy.max(a, axis=None) -> float64

Return the maximum finite float64 value of a nonempty supported array, without modifying it or allocating array storage. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Return the maximum finite float64 value of a nonempty supported array, without modifying it or allocating array storage.

Return the maximum finite float64 value of a nonempty supported array, without modifying it or allocating array storage. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

Argument 1: a: A supported finite float64 array; mean and extrema require at least one element, while sum accepts an empty array.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: An independent float64 scalar; the input array is unchanged.

View example: reductions

numpy.mean(a, axis=None) -> float64

Return the fixed pairwise float64 total divided by the element count. Empty arrays raise ValueError. Intermediate sum overflow raises OverflowError even when the mathematical mean is finite. axis accepts None, 0 or -1. Fixed balanced pairwise binary64 accumulation; no bitwise NumPy guarantee. No dtype/out/keepdims/where/initial, sequence coercion or method form.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Return the fixed pairwise float64 total divided by the element count. Empty arrays raise ValueError. Intermediate sum overflow raises OverflowError even when the mathematical mean is finite.

Return the fixed pairwise float64 total divided by the element count. Empty arrays raise ValueError. Intermediate sum overflow raises OverflowError even when the mathematical mean is finite. axis accepts None, 0 or -1. Fixed balanced pairwise binary64 accumulation; no bitwise NumPy guarantee. No dtype/out/keepdims/where/initial, sequence coercion or method form.

Argument 1: a: A supported finite float64 array; mean and extrema require at least one element, while sum accepts an empty array.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: An independent float64 scalar; the input array is unchanged.

View example: sum-mean

numpy.min(a, axis=None) -> float64

Return the minimum finite float64 value of a nonempty supported array, without modifying it or allocating array storage. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Return the minimum finite float64 value of a nonempty supported array, without modifying it or allocating array storage.

Return the minimum finite float64 value of a nonempty supported array, without modifying it or allocating array storage. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

Argument 1: a: A supported finite float64 array; mean and extrema require at least one element, while sum accepts an empty array.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: An independent float64 scalar; the input array is unchanged.

View example: reductions

numpy.multiply(x1, x2, /) -> array1d-float64

Multiply two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

x1: positional-only; required

x2: positional-only; required

Multiply two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

Multiply two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: arithmetic

numpy.negative(x, /) -> array1d-float64

Negate every element of a supported array into independent storage, preserving IEEE signed-zero negation.

x: positional-only; required

Negate every element of a supported array into independent storage, preserving IEEE signed-zero negation.

Negate every element of a supported array into independent storage, preserving IEEE signed-zero negation.

Argument 1: x: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: elementwise

numpy.ones(shape, dtype='float64') -> array1d-float64

Create a one-dimensional float64 array filled with one; shape is an integer or a one-item tuple/list.

shape: positional-or-keyword; required

dtype: positional-or-keyword; default 'float64'

Create a one-dimensional float64 array filled with one; shape is an integer or a one-item tuple/list.

Create a one-dimensional float64 array filled with one; shape is an integer or a one-item tuple/list.

Argument 1: shape: See the fixed operation signature and contract.

Argument 2: dtype: Float64 string; required unless the signature supplies its default.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: constructors

numpy.sqrt(x, /) -> array1d-float64

Take the square root of each nonnegative element of a supported array into independent storage. Negative elements are outside the finite real profile and raise ValueError.

x: positional-only; required

Take the square root of each nonnegative element of a supported array into independent storage. Negative elements are outside the finite real profile and raise ValueError.

Take the square root of each nonnegative element of a supported array into independent storage. Negative elements are outside the finite real profile and raise ValueError.

Argument 1: x: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: elementwise

numpy.subtract(x1, x2, /) -> array1d-float64

Subtract two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

x1: positional-only; required

x2: positional-only; required

Subtract two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

Subtract two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: arithmetic

numpy.sum(a, axis=None) -> float64

Return a finite float64 total using a fixed balanced pairwise sum. Empty arrays return +0.0. Intermediate overflow raises OverflowError even if a different ordering could finish finitely. axis accepts None, 0 or -1. Fixed balanced pairwise binary64 accumulation; no bitwise NumPy guarantee. No dtype/out/keepdims/where/initial, sequence coercion or method form.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Return a finite float64 total using a fixed balanced pairwise sum. Empty arrays return +0.0. Intermediate overflow raises OverflowError even if a different ordering could finish finitely.

Return a finite float64 total using a fixed balanced pairwise sum. Empty arrays return +0.0. Intermediate overflow raises OverflowError even if a different ordering could finish finitely. axis accepts None, 0 or -1. Fixed balanced pairwise binary64 accumulation; no bitwise NumPy guarantee. No dtype/out/keepdims/where/initial, sequence coercion or method form.

Argument 1: a: A supported finite float64 array; mean and extrema require at least one element, while sum accepts an empty array.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: An independent float64 scalar; the input array is unchanged.

View example: sum-mean

numpy.true_divide(x1, x2, /) -> array1d-float64

True-division alias with the same finite array contract as divide. The engine also supports / and identity-preserving /=; failed in-place division leaves the array unchanged.

x1: positional-only; required

x2: positional-only; required

True-division alias with the same finite array contract as divide. The engine also supports / and identity-preserving /=; failed in-place division leaves the array unchanged.

True-division alias with the same finite array contract as divide. The engine also supports / and identity-preserving /=; failed in-place division leaves the array unchanged.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: division-forms

numpy.zeros(shape, dtype='float64') -> array1d-float64

Create a one-dimensional float64 array filled with zero; shape is an integer or a one-item tuple/list.

shape: positional-or-keyword; required

dtype: positional-or-keyword; default 'float64'

Create a one-dimensional float64 array filled with zero; shape is an integer or a one-item tuple/list.

Create a one-dimensional float64 array filled with zero; shape is an integer or a one-item tuple/list.

Argument 1: shape: See the fixed operation signature and contract.

Argument 2: dtype: Float64 string; required unless the signature supplies its default.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: constructors

Verified fixture examples

Example: arithmetic

*import numpy as np
def main():
    a=np.array([1, 2, -3], dtype="float64")
    b=np.array([2, -1, 4], dtype="float64")
    print(np.add(a,b).tolist(), np.subtract(a,b).tolist(), np.multiply(a,b).tolist())
    print((a+b).tolist(), (a-b).tolist(), (a*b).tolist())
    print((2+a).tolist(), (2-a).tolist(), (2*a).tolist())
    print((a+2).tolist(), (a-2).tolist(), (a*2).tolist())
    print((-a).tolist(), (+a).tolist())
    return 0

Expected standard output:

[3.0, 1.0, 1.0] [-1.0, 3.0, -7.0] [2.0, -2.0, -12.0]
[3.0, 1.0, 1.0] [-1.0, 3.0, -7.0] [2.0, -2.0, -12.0]
[3.0, 4.0, -1.0] [1.0, 0.0, 5.0] [2.0, 4.0, -6.0]
[3.0, 4.0, -1.0] [-1.0, 0.0, -5.0] [2.0, 4.0, -6.0]
[-1.0, -2.0, 3.0] [1.0, 2.0, -3.0]

Expected exit code: 0

Example: concatenation

*import numpy as np
def main():
    a=np.array([1,2],dtype="float64")
    b=np.array([-0.0,3],dtype="float64")
    empty=np.zeros(0)
    c=np.concatenate((a,empty,b),axis=-1)
    c[0]=99
    print(c.tolist(),a.tolist(),b.tolist())
    print(np.concatenate([empty],axis=None).tolist())
    print(np.concatenate([a,b]).tolist())
    return 0

Expected standard output:

[99.0, 2.0, -0.0, 3.0] [1.0, 2.0] [-0.0, 3.0]
[]
[1.0, 2.0, -0.0, 3.0]

Expected exit code: 0

Example: constructors

*import numpy as np
def main():
    a=np.array([1, 2.5, True], dtype="float64")
    print(a.tolist(), a.shape, a.size, a.ndim, len(a))
    print(np.zeros(3).tolist(), np.ones((2,)).tolist())
    print(np.full([3], -2, dtype="float64").tolist())
    return 0

Expected standard output:

[1.0, 2.5, 1.0] (3,) 3 1 3
[0.0, 0.0, 0.0] [1.0, 1.0]
[-2.0, -2.0, -2.0]

Expected exit code: 0

Example: division-forms

*import numpy as np
def main():
    a=np.array([8, -4, -0.0, 5e-324], dtype="float64")
    b=np.array([2, -2, 4, 1], dtype="float64")
    print(np.divide(a,b).tolist(), np.true_divide(a,b).tolist(), (a/b).tolist())
    print((a/2).tolist(), (2/b).tolist(), (a/True).tolist())
    print(a.tolist(), b.tolist())
    return 0

Expected standard output:

[4.0, 2.0, -0.0, 5e-324] [4.0, 2.0, -0.0, 5e-324] [4.0, 2.0, -0.0, 5e-324]
[4.0, -2.0, -0.0, 0.0] [1.0, -1.0, 0.5, 2.0] [8.0, -4.0, -0.0, 5e-324]
[8.0, -4.0, -0.0, 5e-324] [2.0, -2.0, 4.0, 1.0]

Expected exit code: 0

Example: elementwise

*import numpy as np
def main():
    a=np.array([-4, -0.0, 9, 16], dtype="float64")
    print(np.negative(a).tolist())
    print(np.absolute(a).tolist())
    print(np.sqrt(np.absolute(a)).tolist())
    print(np.divide(a,2).tolist())
    print(np.divide(2,np.array([1,2,4,8],dtype="float64")).tolist())
    print(a.tolist())
    return 0

Expected standard output:

[4.0, 0.0, -9.0, -16.0]
[4.0, 0.0, 9.0, 16.0]
[2.0, 0.0, 3.0, 4.0]
[-2.0, -0.0, 4.5, 8.0]
[2.0, 1.0, 0.5, 0.25]
[-4.0, -0.0, 9.0, 16.0]

Expected exit code: 0

Example: independent-copies

*import numpy as np
def main():
    a=np.array([1, 2], "float64")
    b=a
    c=np.copy(a)
    d=np.array(a, dtype="float64")
    e=a.copy()
    b[0]=9
    print(a.tolist(), c.tolist(), d.tolist(), e.tolist(), a is b, a is c)
    return 0

Expected standard output:

[9.0, 2.0] [1.0, 2.0] [1.0, 2.0] [1.0, 2.0] True False

Expected exit code: 0

Example: reductions

*import numpy as np
def main():
    a=np.array([4, -3, 8, -3, 8], dtype="float64")
    print(np.min(a), np.max(a), np.argmin(a), np.argmax(a))
    print(np.min(a, 0), np.max(a, -1), np.argmin(a, axis=None), np.argmax(a, axis=0))
    print(a.tolist())
    return 0

Expected standard output:

-3.0 8.0 1 2
-3.0 8.0 1 2
[4.0, -3.0, 8.0, -3.0, 8.0]

Expected exit code: 0

Example: sum-mean

*import numpy as np
def main():
    a=np.array([1,2,3,4],dtype="float64")
    print(np.sum(a), np.mean(a))
    print(np.sum(a,0), np.mean(a,-1))
    print(np.sum(a=a,axis=None), np.mean(axis=0,a=a))
    print(a.tolist())
    return 0

Expected standard output:

10.0 2.5
10.0 2.5
10.0 2.5
[1.0, 2.0, 3.0, 4.0]

Expected exit code: 0