dpilger26/NumCpp

Digitize is not a member of nc

amarrerod opened this issue · 3 comments

Describe the bug
I'm trying to use the digitize function but for some reason, the code doesn't compile correctly. However, if I just copy and paste the entire code from your digitize.hpp file it works.

Screenshots

//  Creates a vector with a single value
        const nc::NdArray<float> x = {descriptor[i]};
        const nc::NdArray<float> bin = this->bins[i];
        auto location = nc::digitize(x, bin);

The GCC output is the following:

/home/(...)/generator/MapElites.h:252:29: error: ‘digitize’ no es un miembro de ‘nc’
[build]   252 |         auto location = nc::digitize(x, bin);
[build]       |                             ^~~~~~~~

It is hard to tell from your code snippet, probably missing an include I would guess. This minimal example compiles and runs just fine:

#include "NumCpp.hpp"

#include <iostream>

int main()
{
    const auto x          = nc::random::rand<double>({ 1, 10 }) * 10.;
    const auto bins       = nc::linspace<double>(0., 10., 10.);
    const auto xDigitized = nc::digitize(x, bins);

    std::cout << "x         : " << x;
    std::cout << "xDigitized: " << xDigitized;

    return EXIT_SUCCESS;
}

which outputs:

x         : [[7.86821, 2.5048, 7.10671, 9.46668, 0.192711, 4.04902, 2.51318, 0.227124, 5.20643, 3.4467, ]]
xDigitized: [[8, 3, 7, 9, 1, 4, 3, 1, 5, 4, ]]

I tried the snippet above and it does work on my computer. However, the thing is that I also use nc::linspace in the same file and it works just fine.

Closing due to inactivity. Above example compiles and runs. Cannon reproduce users issue, most likely caused by a missing include in their code.