question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New da.tile implementation

See original GitHub issue

Someone privately sent me this da.tile implementation.

def tile(A, reps):
    try:
        tup = tuple(reps)
    except TypeError:
        tup = (reps,)
    d = len(tup)
    if (d < A.ndim):
        tup = (1,)*(A.ndim-d) + tup
    nnd = len(tup) - A.ndim # Number of new dimensions
    final_shape = tup[:nnd]+tuple(i*di for i,di in zip(tup[nnd:],A.shape))
    if 0 in final_shape:
        XXXXX # how to make empty array?
    tup = tup[nnd:]
    # Don't tile along dimensions that can be broadcasted
    tup = tuple(1 if l == 1 else r for l, r in zip(A.shape, tup))
    if all(i==1 for i in tup):
        return da.broadcast_to(A, final_shape)
    name = 'tile-'+dask.base.tokenize('tile', A.name, tup)
    dsk = dict(zip(itertools.product([name], *tuple(range(r*len(c)) for r,c in zip(tup, A.chunks))),
                   itertools.product([A.name], *tuple(r*range(len(c)) for r,c in zip(tup, A.chunks)))))
    ary =  da.Array(sharedict.merge(A.dask, dsk), name, tuple(r*c for r,c in zip(tup, A.chunks)), A.dtype)
    return da.broadcast_to(ary, final_shape)

I haven’t yet gone through it. If anyone feels like an easy contribution this could be checked and tests could be added

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
mrocklincommented, Jan 30, 2019
mrocklin@carbon:~/workspace/dask$ git grep "def tile"
dask/array/creation.py:def tile(A, reps):
0reactions
jakirkhamcommented, Jun 10, 2019

FWIW one could probably solve this issue today by implementing da.tile using da.block.

In [1]: import dask.array as da                                                 

In [2]: a = da.asarray([0, 1, 2])                                               

In [3]: da.block(3 * [4 * [a]]).compute()                                       
Out[3]: 
array([[0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2],
       [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2],
       [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]])
Read more comments on GitHub >

github_iconTop Results From Across the Web

Daltile launches new visualizer | News - Floor Covering Weekly
This new digital tool allows the shopper to visualize products in one of two ways. Consumers can upload an actual photo of a...
Read more >
What's new for Daltile in 2022? - YouTube
Interview with Patrick Warren and Chip Wade during The International Surfaces Event in Las Vegas NV.Join Chip & Patrick for a tour of...
Read more >
Tile & Natural Stone FAQs - Daltile
Tile, grout, sealants, slip resistance, installation - there are A LOT of questions that arise ... Daltile product experts answer your most asked...
Read more >
Dal-Tile overcomes manual process and reporting | Domo
Challenge: This tile manufacturer struggled to overcome manual processes and siloed systems. Solution: Dal-Tile's finance department was able to implement Domo ...
Read more >
Daltile - Ceramic Tile - The Home Depot
Yes, Daltile Ceramic Tile can be returned within our 90-Day return period. What are the shipping options for Daltile Ceramic Tile? Some ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found