Browse Source

remove unnecessary code.

tags/v0.12
Oceania2018 6 years ago
parent
commit
23a9fc9560
2 changed files with 0 additions and 54 deletions
  1. +0
    -33
      src/TensorFlowNET.Core/Binding.Util.cs
  2. +0
    -21
      test/TensorFlowNET.UnitTest/PythonBaseTests.cs

+ 0
- 33
src/TensorFlowNET.Core/Binding.Util.cs View File

@@ -277,39 +277,6 @@ namespace Tensorflow
return (__memberobject__.Length > 0) ? true : false;
}

public delegate object __object__(params object[] args);

public static __object__ getattr(object obj, string key, params Type[] ___parameter_type__)
{
var __dyn_obj__ = obj.GetType().GetMember(key);
if (__dyn_obj__.Length == 0)
throw new Exception("The object \"" + nameof(obj) + "\" doesnot have a defination \"" + key + "\"");
var __type__ = __dyn_obj__[0];
if (__type__.MemberType == System.Reflection.MemberTypes.Method)
{
try
{
var __method__ = (___parameter_type__.Length > 0) ? obj.GetType().GetMethod(key, ___parameter_type__) : obj.GetType().GetMethod(key);
return (object[] args) => __method__.Invoke(obj, args);
}
catch (System.Reflection.AmbiguousMatchException ex)
{
throw new Exception("AmbigousFunctionMatchFound : (Probable cause : Function Overloading) Please add parameter types of the function.");
}
}
else if (__type__.MemberType == System.Reflection.MemberTypes.Field)
{
var __field__ = obj.GetType().GetField(key).GetValue(obj);
return (object[] args) => { return __field__; };
}
else if (__type__.MemberType == System.Reflection.MemberTypes.Property)
{
var __property__ = obj.GetType().GetProperty(key).GetValue(obj);
return (object[] args) => { return __property__; };
}
return (object[] args) => { return "NaN"; };
}

public static IEnumerable TupleToEnumerable(object tuple)
{
Type t = tuple.GetType();


+ 0
- 21
test/TensorFlowNET.UnitTest/PythonBaseTests.cs View File

@@ -49,27 +49,6 @@ namespace TensorFlowNET.UnitTest
Assert.IsFalse(false2);
Assert.IsFalse(false3);
}

[TestMethod]
public void hasattr_getattr()
{
var s1 = "Tensorflow v0.1";
var f = "Tensorflow";
var r = "Tensorflow.NET";
var res = s1.Replace(f, r);

// Test 1
Assert.IsTrue(hasattr(s1, "Replace"));

// Test 2
var o = getattr( s1, "Replace", typeof(string), typeof(string));
Assert.AreEqual(res, o(f, r));

// Test 3
var l = getattr(s1, "Length");
Assert.AreEqual(s1.Length, l());

}
}
}


Loading…
Cancel
Save