Quansight-Labs / numpy.net

A port of NumPy to .Net
BSD 3-Clause "New" or "Revised" License
128 stars 14 forks source link

Consider using .NET interactive notebooks #35

Open GeorgeS2019 opened 2 years ago

GeorgeS2019 commented 2 years ago

There are many console apps used to demo numpy.net

As an alternative, consider porting numpy tutorials or examples provided by numpy textbook to demo the almost close to 1-to-1 coverage of numpy functions using numpy.net and distribute that to new users using .NET interactive notebook instead of jupyter notebook.

GeorgeS2019 commented 1 year ago
public void print(object obj)
{
    if (obj == null)
    {
        Console.WriteLine("<null>");
        return;
    }
    if (obj is Array)
    {
        foreach (var o in (Array)obj)
        {
            Console.Write(o.ToString() + ",");
        }
        Console.WriteLine("");
    }
    else
    {
        Console.WriteLine(obj.ToString());
    }
}
public void print(string label, object obj)
{
    Console.WriteLine(label + obj.ToString());
}
public void print<T>(string label, T[] array)
{
    Console.WriteLine(label + ArrayToString(array));
}

public string ArrayToString<T>(T[] array)
{
    StringBuilder sb = new StringBuilder();

    sb.Append("[");

    foreach (T t in array)
    {
        sb.Append(t.ToString());
        sb.Append(",");
    }

    sb.Append("]");

    return sb.ToString();
}
KevinBaselinesw commented 1 year ago

Hi George,

It is not clear what you are asking. Do you think there is a bug in the print function? Is there a bug in the np.arange function?

GeorgeS2019 commented 1 year ago

@KevinBaselinesw I would like to encourage more users to start sharing Numpy Notebooks using NumpyDotNet

This issue is to track the experience of using NumpyDotNet and how the output may or may not be similar to that generated from python in Notebooks.

KevinBaselinesw commented 1 year ago

let me know what I can do to help.

FYI, I am not familiar with Numpy Notebooks so you may have provide some additional information to me.

GeorgeS2019 commented 1 year ago

@KevinBaselinesw The first question most users would like to know what is your numpy's coverage and how it is related to the existing numpy version

I found

arraysetos.cs
.. versionadded:: 1.13.0

Does this mean not all codes are of similar version??

This need to be tracked in a e.g. release

In TorchSharp, it is communicated through discussion.

GeorgeS2019 commented 1 year ago

For notebook, I am searching for e.g. numpy 101 that provides notebook that show use cases of different topics of numpy. Ideally, as a community, we use NumpyDotNet to complete such notebook in c#

KevinBaselinesw commented 1 year ago

I don't have a perfect match between numpydotnet and a specific version of numpy. The brief history is that I inherited an abandoned attempt to create a .net version of Numpy that was hybrid of C# and C. Most of the python code was removed. That code probably only implemented 25% of the numpy API. I took that code, ported the C code to C#, eliminated all of the interop code, debugged it and then ported the rest missing numpy API to C#. Most of the porting that I did was from version .17 if I remember correctly. The good news is that there really is not much difference between the various versions of Numpy. That API doesn't really change much from version to version.

GeorgeS2019 commented 1 year ago

Great, now we have the background, we need. We appreciate how much work you have done. Thanks.

KevinBaselinesw commented 1 year ago

For notebook, I am searching for e.g. numpy 101 that provides notebook that show use cases of different topics of numpy. Ideally, as a community, we use NumpyDotNet to complete such notebook in c#

Are you trying to recreate a dynamic site like this for python numpy?

https://www.w3resource.com/python-exercises/numpy/python-numpy-exercise-1.php

GeorgeS2019 commented 1 year ago

@KevinBaselinesw The priority is to persuade the .NET communities to focus on ONE effort on NumPy.

The good news is that there really is not much difference between the various versions of Numpy. That API doesn't really change much from version to version.

The communities need some way to know how GREAT the coverage and hopefully, someone will step forwards to update the communities with each release of the python version on the .NET minor changes needed to keep up with the latest python NumPy release.

Right now, these TWO criteria exist for TorchSharp BUT are absent in many other efforts. Although TorchSharp still has A LOT to cover, the communities have started to be more and more feeling confident of the TorchSharp effort.

ALL THESE may look trivial, BUT it is for the GREATER GOOD!