[SciPy-User] array creation

Oleksandr Huziy guziy.sasha at gmail.com
Wed Nov 11 16:50:36 EST 2015


Elmar:


You could use smth like this....

import itertools as itt
import numpy as np


def foo(ncol=1, start=0, end=10, delta=0.1):
    if ncol==1:
        return np.arange(start, end, delta)
    else:
        ranges = ncol * [np.arange(start, end, delta), ]
        for z in itt.product(*ranges):
            yield z


for (x1, x2) in foo(ncol=2):
     print(x1, x2)

This is not exactly what you need but might help.

Cheers






2015-11-11 14:17 GMT-05:00 elmar werling <elmar at net4werling.de>:

> with the following pattern
>
> the pattern is
>
> 0    100    0
> 0    0    100
> 10    90    0
> 10    80    10
> 10    70    20
> 10    60    30
> 10    50    40
> 10    40    50
> 10    30    60
> 10    20    70
> 10    10    80
> 10    0    90
> 20    80    0
> 20    70    10
> 20    60    20
> 20    50    30
> 20    40    40
> 20    30    50
> 20    20    60
> 20    10    70
> 20    0    80
> 30    70    0
> 30    60    10
> 30    50    20
> 30    40    30
> 30    30    40
> 30    20    50
> 30    10    60
> 30    0    70
> ...   ...  ...
>
> On 11.11.2015 19:44, Max Shron wrote:
>
>> Can you specify a little more clearly what you're looking for? I'm not
>> seeing the pattern.
>>
>> On Wed, Nov 11, 2015 at 1:12 PM, elmar werling <elmar at net4werling.de
>> <mailto:elmar at net4werling.de>> wrote:
>>
>>     Hi,
>>
>>     is there a function foo(ncols, min, max, delta) in mumpy/scipy to
>>     create an array such as
>>
>>     0       100     0
>>     0       0       100
>>     10      90      0
>>     10      80      10
>>     10      70      20
>>     10      60      30
>>     10      50      40
>>     10      40      50
>>     10      30      60
>>     20      20      70
>>     20      10      80
>>     20      0       90
>>     20      80      0
>>     ...     ...     ...
>>     90      10      0
>>     90      0       10
>>     100     0       0
>>
>>     Any help or link is welcome
>>
>>     Elmar
>>
>>
>>     _______________________________________________
>>     SciPy-User mailing list
>>     SciPy-User at scipy.org <mailto:SciPy-User at scipy.org>
>>     https://mail.scipy.org/mailman/listinfo/scipy-user
>>
>>
>>
>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User at scipy.org
>> https://mail.scipy.org/mailman/listinfo/scipy-user
>>
>>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> https://mail.scipy.org/mailman/listinfo/scipy-user
>



-- 
Sasha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20151111/eb8055ad/attachment.html>


More information about the SciPy-User mailing list