开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (5)
标签 (9)
master
Python3.7_OSX
Python3.6_OSX
Python3.6_Mono
Python3.6
v1.17
vX.X.1.5
v3.7.1.4_osx
v3.6.1.4_osx
v3.6.1.4_mono
v3.6.1.4
v3.7.1.4
v3.6.1.3
v3.7.1.3
master
分支 (5)
标签 (9)
master
Python3.7_OSX
Python3.6_OSX
Python3.6_Mono
Python3.6
v1.17
vX.X.1.5
v3.7.1.4_osx
v3.6.1.4_osx
v3.6.1.4_mono
v3.6.1.4
v3.7.1.4
v3.6.1.3
v3.7.1.3
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (5)
标签 (9)
master
Python3.7_OSX
Python3.6_OSX
Python3.6_Mono
Python3.6
v1.17
vX.X.1.5
v3.7.1.4_osx
v3.6.1.4_osx
v3.6.1.4_mono
v3.6.1.4
v3.7.1.4
v3.6.1.3
v3.7.1.3
Numpy.NET
/
src
/
Numpy
/
Models
/
PythonObject.gen.cs
Numpy.NET
/
src
/
Numpy
/
Models
/
PythonObject.gen.cs
PythonObject.gen.cs 5.84 KB
一键复制 编辑 原始数据 按行查看 历史
Meinrad Recheis 提交于 2020年11月08日 02:33 +08:00 . fixed np.savez but loading still fails
// Copyright (c) 2020 by Meinrad Recheis (Member of SciSharp)
// Code generated by CodeMinion: https://github.com/SciSharp/CodeMinion
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Python.Runtime;
using Numpy.Models;
#if PYTHON_INCLUDED
using Python.Included;
#endif
namespace Numpy
{
public partial class PythonObject
{
//auto-generated
public PyTuple ToTuple(Array input)
{
var array = new PyObject[input.Length];
for (int i = 0; i < input.Length; i++)
{
array[i]=ToPython(input.GetValue(i));
}
return new PyTuple(array);
}
//auto-generated
public PyObject ToPython(object obj)
{
if (obj == null) return Runtime.None;
switch (obj)
{
// basic types
case int o: return new PyInt(o);
case long o: return new PyLong(o);
case float o: return new PyFloat(o);
case double o: return new PyFloat(o);
case string o: return new PyString(o);
case bool o: return ConverterExtension.ToPython(o);
case PyObject o: return o;
// sequence types
case Array o: return ToTuple(o);
// special types from 'ToPythonConversions'
case Axis o: return o.Axes==null ? null : ToTuple(o.Axes);
case Shape o: return ToTuple(o.Dimensions);
case Slice o: return o.ToPython();
case PythonObject o: return o.PyObject;
case Dictionary<string, NDarray> o: return ToDict(o);
default: throw new NotImplementedException($"Type is not yet supported: { obj.GetType().Name}. Add it to 'ToPythonConversions'");
}
}
//auto-generated
public T ToCsharp<T>(dynamic pyobj)
{
switch (typeof(T).Name)
{
// types from 'ToCsharpConversions'
case "Dtype": return (T)(object)new Dtype(pyobj);
case "NDarray": return (T)(object)new NDarray(pyobj);
case "NDarray`1":
switch (typeof(T).GenericTypeArguments[0].Name)
{
case "Byte": return (T)(object)new NDarray<byte>(pyobj);
case "Short": return (T)(object)new NDarray<short>(pyobj);
case "Boolean": return (T)(object)new NDarray<bool>(pyobj);
case "Int32": return (T)(object)new NDarray<int>(pyobj);
case "Int64": return (T)(object)new NDarray<long>(pyobj);
case "Single": return (T)(object)new NDarray<float>(pyobj);
case "Double": return (T)(object)new NDarray<double>(pyobj);
default: throw new NotImplementedException($"Type NDarray<{typeof(T).GenericTypeArguments[0].Name}> missing. Add it to 'ToCsharpConversions'");
}
break;
case "NDarray[]":
var po = pyobj as PyObject;
var len = po.Length();
var rv = new NDarray[len];
for (int i = 0; i < len; i++)
rv[i] = ToCsharp<NDarray>(po[i]);
return (T) (object) rv;
case "Matrix": return (T)(object)new Matrix(pyobj);
default:
try
{
return pyobj.As<T>();
}
catch (Exception e)
{
throw new NotImplementedException($"conversion from {typeof(T).Name} to {pyobj.__class__} not implemented", e);
return default(T);
}
}
}
//auto-generated
public T SharpToSharp<T>(object obj)
{
if (obj == null) return default(T);
switch (obj)
{
// from 'SharpToSharpConversions':
case Array a:
if (typeof(T)==typeof(NDarray)) return (T)(object)ConvertArrayToNDarray(a);
break;
}
throw new NotImplementedException($"Type is not yet supported: { obj.GetType().Name}. Add it to 'SharpToSharpConversions'");
}
//auto-generated: SpecialConversions
private static NDarray ConvertArrayToNDarray(Array a)
{
switch(a)
{
case bool[] arr: return np.array(arr);
case int[] arr: return np.array(arr);
case float[] arr: return np.array(arr);
case double[] arr: return np.array(arr);
case int[,] arr: return np.array(arr.Cast<int>().ToArray()).reshape(arr.GetLength(0), arr.GetLength(1));
case float[,] arr: return np.array(arr.Cast<float>().ToArray()).reshape(arr.GetLength(0), arr.GetLength(1));
case double[,] arr: return np.array(arr.Cast<double>().ToArray()).reshape(arr.GetLength(0), arr.GetLength(1));
case bool[,] arr: return np.array(arr.Cast<bool>().ToArray()).reshape(arr.GetLength(0), arr.GetLength(1));
default: throw new NotImplementedException($"Type {a.GetType()} not supported yet in ConvertArrayToNDarray.");
}
}
//auto-generated: SpecialConversions
private static PyDict ToDict(Dictionary<string, NDarray> d)
{
var dict = new PyDict();
foreach (var pair in d)
dict[new PyString(pair.Key)] = pair.Value.self;
return dict;
}
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

The most complete .NET bindings for NumPy
取消

发行版

暂无发行版

贡献者

全部

语言

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/pxp/Numpy.NET.git
git@gitee.com:pxp/Numpy.NET.git
pxp
Numpy.NET
Numpy.NET
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /