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.

The matrix generators for provider Numbers()

See original GitHub issue

Feature request

Thesis

The matrix can be useful in working in Jupyter Notebook. So, it would be awesome to support generators of matrix in provider Numbers().

I sketched a rough implementation example:

import random

from typing import Tuple, Optional, Union, List

ValuesRange = Union[
    List[int],
    Tuple[int, int],
]


def matrix(m: int = 3, n: int = 3, values_range: Optional[ValuesRange] = None) -> list:
    """Creates an 𝑚×𝑛 matrix which has 𝑚 rows and 𝑛 columns.

    :param m: Rows count.
    :param n: Columns count.
    :param values_range: Range of values of matrix items.
    :return: Matrix 𝑚×𝑛.
    """
    if values_range is None:
        values_range = (-100, 100)

    if len(values_range) > 2:
        raise ValueError('Invalid items range! Usage example: items_range=(-10, 10)')

    result = [
        [random.randint(*values_range) for _ in range(m)]
        for _ in range(n)
    ]

    return result

matrix(m=5, n=4, values_range=[-50, 50])

Output:

[[29, 7, 17, -24, -29],
 [-26, 13, 29, -25, 6],
 [-5, 16, 13, -45, 49],
 [23, 20, -25, 14, -25]]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
lk-geimfaricommented, Oct 1, 2019
0reactions
lk-geimfaricommented, Oct 18, 2019

@gupta-kartik20 Sure! I’ll wait for PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generate Random Matrices - Online Math Tools
World's simplest online utility that generates random matrices. Free, quick, and powerful. Press a button, get a random matrix.
Read more >
Generator matrix - Wikipedia
In coding theory, a generator matrix is a matrix whose rows form a basis for a linear code. The codewords are all of...
Read more >
Pseudo-Random Numbers - Math.NET Numerics
All random number generators (RNG) generate numbers in a uniform distribution. ... NET Numerics and open the namespaces for random numbers and probability ......
Read more >
Generators - ApplicationSet Controller
Matrix generator : The Matrix generator may be used to combine the generated parameters of two separate generators.
Read more >
Matrix Generator XLATMR
from the Independent Sets and Generators ; Source: LAPACK ; Discipline: Numerical linear algebra ; Language: Fortran ; Output format: Matrix Market format,...
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