I want to find Max number from a column, but i don't find Max( ) method with my Events class?
It's an extension method and you haven't included the System.Linq namespace.
Related
in the OPAL framework, is it possible to manually create an annotated method?
I currently have the following code:
Method(0, "signaturePolymorphicMethod",
MethodDescriptor(ObjectType("java/lang/Object"), VoidType), Seq())
and I want to add the annotation
#java.lang.invoke.MethodHandle$PolymorphicSignature
to this method. How can I do this?
Annotations are generally stored using the JVM's general "Attributes" mechanism.
In this case the annotation is a non-public inner class of MethodHandle with the "Runtime Retention Policy". Hence, to mark a method as having a "Polymorphic Signature" it is necessary to add the RuntimeVisibibleAnnotations_Attribute to the respective method's attributes table. However, given that the visibility of the annotation is limited to the java.lang.invoke package this is (in this specific case) probably rarely useful. Nevertheless, it is possible to query methods in the respective package
How do you get help for a class method/function when there are other functions of the same name?
For example, the predict method/function works for both TreeBagger and GeneralizedLinearModel class.
How do I get the respective helpfiles for these functions using doc, as currently doc predict returns the help for the CompactClassificationTree class?
http://www.mathworks.com/help/stats/treebagger.predict.html
http://www.mathworks.com/help/stats/generalizedlinearmodel.predict.html
predict is a method of each class. You can also call it like myTreeBagger.predict(data)
Is there a quick way to count the number of methods in a MATLAB class ?
obj = myClassName()
Is there a way to get the number of methods inside this class?
Yes! At least in MatlabR2014b you can use methods
example:
methods('SURFPoints')
or
methods('myClassName')
Probably you would be able to find it with a quick google but you mix your terminology a bit. myClassName() is a class, and all the functions that are specific of this class and are "inside" it are called methods. Do not call method to a class! There is nothing like "number of functions used in a method" (well, there is but its definitely not what you are looking for).
You can use:
a = ?MyClassName;
numMethods = numel(a.MethodList);
Here a is a metaclass object that contains all the details of the class MyClassName, such as its package, properties, methods, events etc.
I have followed the link Can I find number of methods without number of getters via CQL? and excluded the properties from one of my NDepend queries.
One of our coding guidelines is also to ensure that the number of properties in a class(including auto-properties) should not exceed 10.(To be consistent with another guideline that no more than 20 methods can be defined for a class.)
The problem is even if we have 10 properties in a class, which is within the defined limits, the number of methods is being shown as 20. I understand that this is because a get_ and set_ for a single property are being counted as two different methods. But is there any way, by which we can change the NDepend query to have the get_ and set_ methods for a property to be counted as a single method?
Thanks
Here is a CQLinq rules that warn for types having more than 10 properties and that lists the properties through a getter or (exclusive) a setter. The astute consists in using a Lookup table where getters and/or setters are indexed by the property name, inferred from getter/setter names:
// <Name>A class should not have more than 10 properties</Name>
warnif count > 0
from t in Application.Types
let accessers = t.Methods.Where(m => m.IsPropertyGetter || m.IsPropertySetter)
where accessers.Count() > 0 // Optimization!
// Here we build a lookup that associate for each property name, the getter, the setter, or both.
// The property name is getter and/or setter simple names, without "get_" or "set_" prefixes (4 chars).
let propertiesLookup = accessers.ToLookup(a => a.SimpleName.Substring(4, a.SimpleName.Length -4))
where propertiesLookup.Count() > 10
let properties = propertiesLookup.Select(p => p.First())
select new { t, properties }
This rule also lists properties for each matched class.
We have demand on our User Voice for creating an NDepend.CodeModel.IProperty interface, that will make such rule easier to develop, don't hesitate to vote for this!
I can use add_class("classname") to add a class attribute to one of my elements, but I can also use attribute("class", "classname") to do the same.
What's the difference between the two functions? Any gotchas?
Yup, the tritium function add_class(...) will append the given argument to the class attribute in the node you're currently in (also prepending a space to separate it from other class names).
On the other hand, calling attribute("class", "classname") will actually clobber whatever class names already existed with the value you provided.
Below is an example illustrating both in tritium tester:
http://tritium.moovweb.com/43ecf5fdbc4bf6b07312372724df5a2522474cc3