numpy — 0.6.0

org.pycforge.numpy · Author: PyCForge

License: GPL-3.0-only · Created: 2026-11-05

Runtime conversion · Direct declared calls

Function index

absolute · add · argmax · argmin · array · concatenate · copy · divide · dot · 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

Owned contiguous one-dimensional finite float64 arrays, Runtime only. No dtype inference, views, slicing, external buffers, matrices, complex values or general broadcasting. Assignment/arguments share arrays; constructors, copy and arithmetic allocate independent storage. Integer indexing, finite item assignment, len, iteration/reversed, copy()/tolist() and shape/size/ndim are supported. Allocation/work use context budgets; exhaustion is fatal. Ordinary type, shape and bounds errors are catchable. Arrays remain valid in their context until destruction or collection without a live root. Generated C needs no Python/NumPy runtime. Min/max require nonempty arrays and reject mixed-sign zero extrema; argmin/argmax return the first tie. Reduction axis accepts None, integer 0 or -1. No reduction methods, sequence coercion, axis tuples, out, dtype, keepdims, initial or where. Negative/absolute/sqrt return independent arrays; negative square roots are refused. Concatenate accepts a nonempty list/tuple of arrays, including empty arrays; axis=None, 0 or -1. Divide/true_divide and / require an array, equal array lengths and nonzero divisors. Zero divisors raise ValueError; nonfinite results raise OverflowError. In-place /= retains identity/aliases and preserves all elements on failure. Empty division performs no element operations. No floor division or remainder. Sum/mean return independent float64 scalars without array allocation or mutation; a and axis accept positional/named arguments. The fixed sum tree splits at floor(length/2), left then right, rounding each addition to binary64. Mean divides by the exact length (at most 2**53). Empty sum is +0.0; empty mean raises ValueError. Dot(a,b) accepts positional/named arguments evaluated once in source order. Both must be equal-length supported arrays; no scalar/sequence coercion, out, @ or native BLAS. Each binary64 product rounds separately without fused multiply-add, then uses the sum tree. Dot allocates no heap storage, changes/retains neither input and returns an independent scalar. Sum/mean/dot require nearest ties-to-even rounding and gradual underflow. A different rounding mode raises RuntimeError. Any nonfinite intermediate product/sum raises OverflowError even when the mathematical result is finite. Finite subnormals and underflow to zero are permitted. Empty dot and zero totals are +0.0; mean division may produce signed zero. Inputs are preserved on failure, including fatal work exhaustion. For n>0, u=2**-53, eta=2**-1074, h=ceil(log2(n)), gamma(k)=k*u/(1-k*u), and A=sum(abs(exact input)): absolute sum error <= gamma(h)*A+(n-1)*eta*(1+gamma(h)); mean error <= gamma(h+1)*A/n+2*eta*(1+gamma(h+1)). For dot use A=sum(abs(exact a[i]*b[i])): absolute error <= gamma(h+1)*A+(2*n-1)*eta*(1+gamma(h+1)). Bounds assume nearest rounding, gradual underflow and no intermediate overflow. Cancellation can cause large relative error; NumPy/BLAS may accumulate/fuse differently, so bitwise agreement is not promised. NumPy warning/seterr policies are unsupported. Array printing/formatting, comparisons, dtype objects, NumPy scalar object identity and warning/seterr behavior are unsupported. Arithmetic overflow is refused explicitly; sum/mean/dot have documented rounding bounds and may differ from NumPy.

Release notes

Adds a one-dimensional dot product through profile 0.6; finite separately rounded products and pairwise sums 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.

Owned contiguous one-dimensional finite float64 arrays, Runtime only. No dtype inference, views, slicing, external buffers, matrices, complex values or general broadcasting. Assignment/arguments share arrays; constructors, copy and arithmetic allocate independent storage. Integer indexing, finite item assignment, len, iteration/reversed, copy()/tolist() and shape/size/ndim are supported. Allocation/work use context budgets; exhaustion is fatal. Ordinary type, shape and bounds errors are catchable. Arrays remain valid in their context until destruction or collection without a live root. Generated C needs no Python/NumPy runtime. Min/max require nonempty arrays and reject mixed-sign zero extrema; argmin/argmax return the first tie. Reduction axis accepts None, integer 0 or -1. No reduction methods, sequence coercion, axis tuples, out, dtype, keepdims, initial or where. Negative/absolute/sqrt return independent arrays; negative square roots are refused. Concatenate accepts a nonempty list/tuple of arrays, including empty arrays; axis=None, 0 or -1. Divide/true_divide and / require an array, equal array lengths and nonzero divisors. Zero divisors raise ValueError; nonfinite results raise OverflowError. In-place /= retains identity/aliases and preserves all elements on failure. Empty division performs no element operations. No floor division or remainder. Sum/mean return independent float64 scalars without array allocation or mutation; a and axis accept positional/named arguments. The fixed sum tree splits at floor(length/2), left then right, rounding each addition to binary64. Mean divides by the exact length (at most 2**53). Empty sum is +0.0; empty mean raises ValueError. Dot(a,b) accepts positional/named arguments evaluated once in source order. Both must be equal-length supported arrays; no scalar/sequence coercion, out, @ or native BLAS. Each binary64 product rounds separately without fused multiply-add, then uses the sum tree. Dot allocates no heap storage, changes/retains neither input and returns an independent scalar. Sum/mean/dot require nearest ties-to-even rounding and gradual underflow. A different rounding mode raises RuntimeError. Any nonfinite intermediate product/sum raises OverflowError even when the mathematical result is finite. Finite subnormals and underflow to zero are permitted. Empty dot and zero totals are +0.0; mean division may produce signed zero. Inputs are preserved on failure, including fatal work exhaustion. For n>0, u=2**-53, eta=2**-1074, h=ceil(log2(n)), gamma(k)=k*u/(1-k*u), and A=sum(abs(exact input)): absolute sum error <= gamma(h)*A+(n-1)*eta*(1+gamma(h)); mean error <= gamma(h+1)*A/n+2*eta*(1+gamma(h+1)). For dot use A=sum(abs(exact a[i]*b[i])): absolute error <= gamma(h+1)*A+(2*n-1)*eta*(1+gamma(h+1)). Bounds assume nearest rounding, gradual underflow and no intermediate overflow. Cancellation can cause large relative error; NumPy/BLAS may accumulate/fuse differently, so bitwise agreement is not promised. NumPy warning/seterr policies are unsupported.

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.dot(a, b) -> float64

Return the finite float64 dot product of two equal-length supported arrays. Each product rounds separately, followed by a fixed balanced pairwise sum. Empty arrays return +0.0; intermediate product or sum overflow raises OverflowError.

a: positional-or-keyword; required

b: positional-or-keyword; required

Return the finite float64 dot product of two equal-length supported arrays. Each product rounds separately, followed by a fixed balanced pairwise sum. Empty arrays return +0.0; intermediate product or sum overflow raises OverflowError.

Return the finite float64 dot product of two equal-length supported arrays. Each product rounds separately, followed by a fixed balanced pairwise sum. Empty arrays return +0.0; intermediate product or sum overflow raises OverflowError.

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

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

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

View example: dot-weights

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: dot-weights

*import numpy as np
def main():
    a=np.array([2,4,8],dtype="float64")
    b=np.array([0.5,0.25,-0.5],dtype="float64")
    print(float(np.dot(a,b)),float(np.dot(b=b,a=a)))
    print(a.tolist(),b.tolist())
    print(float(np.dot(np.zeros(0),np.zeros(0))))
    print(float(np.dot(np.array([-0.0],dtype="float64"),np.ones(1)))==0.0)
    events=[]
    def mark(name,value):
        events.append(name)
        return value
    a=np.array([2,3],dtype="float64")
    print(float(np.dot(b=mark("right",a),a=mark("left",a))))
    print(events,a.tolist())
    a=np.array([1,2,3],dtype="float64")
    result=float(np.dot(a,a))
    a[0]=99
    print(result,a.tolist())
    return 0

Expected standard output:

-2.0 -2.0
[2.0, 4.0, 8.0] [0.5, 0.25, -0.5]
0.0
True
13.0
['right', 'left'] [2.0, 3.0]
14.0 [99.0, 2.0, 3.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