Git Product home page Git Product logo

Comments (8)

PumpkinSeed avatar PumpkinSeed commented on May 27, 2024

Hi @halturin,

Can you please provide a use-case or explanation for what you want to see? I just don't understand what is the result what you want to get from gofakeit.

from gofakeit.

halturin avatar halturin commented on May 27, 2024

Thanks for your reply.

i'm just expecting to see kind of [][]float32{nil, []float32{...}, nil, nil} or something. Currently, it fills all the values of any slice.

from gofakeit.

PumpkinSeed avatar PumpkinSeed commented on May 27, 2024

As far as I know this is the closest solution, but it's not generating nil values:

package main

import (
	"fmt"

	"github.com/brianvoe/gofakeit/v6"
)

func main() {
	v := [][]float32{nil, []float32{12}, nil}
	gofakeit.Slice(&v)
	fmt.Println(v)
        // Output: [[6.5598885e+37 2.9083515e+38 1.9996555e+38 7.870126e+37 3.2749926e+37 2.658292e+38 1.0501455e+38] [1.4212272e+38] [1.647583e+38 2.382803e+38 3.0777828e+38 1.395749e+38 1.610417e+38]]
}

I think this requires some modification on the Slice function.

from gofakeit.

halturin avatar halturin commented on May 27, 2024

Unfortunately, it doesn't work. Imagine a multidimensional slice, say [][][][][]float32.

It would be great if the Slice method could check the item type using CanAddr method

from gofakeit.

PumpkinSeed avatar PumpkinSeed commented on May 27, 2024

@halturin I know it does not work, because I said: "I think this requires some modification on the Slice function."

This means that the Slice function does not support such a requirement, so someone needs to add this functionality. :)
Also probably it will be a new function, because of backward compatibility.

from gofakeit.

brianvoe avatar brianvoe commented on May 27, 2024

The problem with this is if i randomized a nil in an array of []float32 I would get the same issue from others wondering why im only partially filling out the array.

This is more of a user issue than anything. Sounds like you should make your own lookup function and output it the way you want.

from gofakeit.

halturin avatar halturin commented on May 27, 2024

Thanks for the reply. As soon as a slice/map can be nil, it's weird not to have the ability to assign nil as a value. It would be great to have another method like gofakeit.SliceWithNil(...) to add the probability of nil values. Up to you.

from gofakeit.

brianvoe avatar brianvoe commented on May 27, 2024

Im good. Thanks.

from gofakeit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.