class documentation

class TestDimSpec(util.F2PyTest):

View In Hierarchy

This test suite tests various expressions that are used as dimension specifications.

There exists two usage cases where analyzing dimensions specifications are important.

In the first case, the size of output arrays must be defined based on the inputs to a Fortran function. Because Fortran supports arbitrary bases for indexing, for instance, arr(lower:upper), f2py has to evaluate an expression upper - lower + 1 where lower and upper are arbitrary expressions of input parameters. The evaluation is performed in C, so f2py has to translate Fortran expressions to valid C expressions (an alternative approach is that a developer specifies the corresponding C expressions in a .pyf file).

In the second case, when user provides an input array with a given size but some hidden parameters used in dimensions specifications need to be determined based on the input array size. This is a harder problem because f2py has to solve the inverse problem: find a parameter p such that upper(p) - lower(p) + 1 equals to the size of input array. In the case when this equation cannot be solved (e.g. because the input array size is wrong), raise an error before calling the Fortran function (that otherwise would likely crash Python process when the size of input arrays is wrong). f2py currently supports this case only when the equation is linear with respect to unknown parameter.

Method test​_array​_size Undocumented
Method test​_inv​_array​_size Undocumented
Class Variable all​_dimspecs Undocumented
Class Variable code Undocumented
Class Variable code​_template Undocumented
Class Variable linear​_dimspecs Undocumented
Class Variable lst Undocumented
Class Variable nonlinear​_dimspecs Undocumented
Class Variable suffix Undocumented

Inherited from F2PyTest:

Method setup Undocumented
Class Variable module​_name Undocumented
Class Variable only Undocumented
Class Variable options Undocumented
Class Variable skip Undocumented
Class Variable sources Undocumented
Instance Variable module Undocumented
@pytest.mark.parametrize('dimspec', all_dimspecs)
def test_array_size(self, dimspec):

Undocumented

@pytest.mark.parametrize('dimspec', all_dimspecs)
def test_inv_array_size(self, dimspec):

Undocumented

all_dimspecs =

Undocumented

code: str =

Undocumented

code_template =

Undocumented

linear_dimspecs: list[str] =

Undocumented

lst =

Undocumented

nonlinear_dimspecs: list[str] =

Undocumented

suffix: str =

Undocumented