Open-Systems-Pharmacology / OSPSuite-R

R package for the OSPSuite
https://www.open-systems-pharmacology.org/OSPSuite-R/
Other
29 stars 12 forks source link

Population$setParameterValues - add check for the number of provided values #424

Open PavelBal opened 4 years ago

PavelBal commented 4 years ago

The number of values must equal the numer of individuals, if I understand it correctly. A check for the correct number should be provided, as now a .net-error is thrown if the number of values does not equal the numer of individuals in the simulation:

Error in rClr::clrCall(self$ref, "SetValues", parameterPath, values) : 
  Type:    OSPSuite.Utility.Exceptions.OSPSuiteException
Message: Parameter values for 'Organism|Weight' does not have the expected number of elements. (Expected 10 vs Actual 2)
Method:  Void validateCount[T](System.String, System.Collections.Generic.IReadOnlyList`1[T])
Stack trace:
   at OSPSuite.Core.Domain.Populations.ParameterValuesCache.validateCount[T](String parameterPath, IReadOnlyList`1 values)
   at OSPSuite.Core.Domain.Populations.ParameterValuesCache.setValues[T](String parameterPath, IReadOnlyList`1 newValues, Func`2 addValuesFunc)
   at OSPSuite.Core.Domain.Populations.ParameterValuesCache.SetValues(String parameterPath, IReadOnlyList`1 newValues)
   at OSPSuite.Core.Domain.Populations.IndividualValuesCache.SetValues(String parameterPath, IReadOnlyList`1 newValues)
msevestre commented 4 years ago

Hum

Parameter values for 'Organism|Weight' does not have the expected number of elements. (Expected 10 vs Actual 2)

Isn't it what that is ?:)

PavelBal commented 4 years ago

Well, kind of :D May be strange for the casual R-user to see this... And when passing only one value, an error about missing method is thrown:

> myPopulation$setParameterValues("Organism|Weight", 50)
Error in rClr::clrCall(self$ref, "SetValues", parameterPath, values) : 
  Type:    System.MissingMethodException
Message: Could not find a suitable instance method SetValues on type OSPSuite.Core.Domain.Populations.IndividualValuesCache for method parameters String, Double
Method:  Void ThrowMissingMethod(System.Type, System.String, System.String, System.Type[])
Stack trace:
   at Rclr.ReflectionHelper.ThrowMissingMethod(Type classType, String methodName, String modifier, Type[] types)
   at Rclr.ClrFacade.InternalCallInstanceMethod(Object obj, String methodName, Boolean tryUseConverter, Object[] arguments)

Probably because of lacking the possibility to pass arrays of length = 1...

msevestre commented 4 years ago

Yes. But a population of one individual... lol. That's not even allowed in PKSim

msevestre commented 4 years ago

This is all fixable obviously but in my opinion very low prior as 1/There is a message that comes from CORE 2/Pop with 1 individual does not make sense (in general, I am sure you have a use case)