Ejemplo n.º 1
0
 /// <summary>
 /// Creates new instance of the TreeSource for the specifed relation
 /// </summary>
 /// <param name="relation">Fuzzy relation to represent as a hierarchical list</param>
 /// <param name="inputs">Set of specified values for particular dimensions.</param>
 /// <param name="variableDimension">Dimension which should be put on the x-axis. Null if we don't want to display graphs, or if we only want to display graphs for single-diemnsional sets.</param>
 public TreeSource(FuzzyRelation relation, Dictionary<IDimension, System.Decimal> inputs, IDimension variableDimension)
 {
     _relation = relation;
     _inputs = inputs;
     _variableDimension = variableDimension;
     treeView_AfterSelect_EventHandler = new TreeViewEventHandler(treeView_AfterSelect);
 }
Ejemplo n.º 2
0
        public Dimension(IDimension dimension)
        {
            if (dimension.HasCodedRepresentation())
            {
                this._isCodelist = true;
                this._codelist = dimension.Representation.Representation.MaintainableReference.MaintainableId;
                this._codelistAgency = dimension.Representation.Representation.MaintainableReference.AgencyId;
                this._codelistVersion = dimension.Representation.Representation.MaintainableReference.Version;
            }
            else {
                this._isCodelist = false;
            }

            this._id = dimension.Id;
            this._conceptRef = dimension.ConceptRef.FullId;
            this._conceptSchemeId= dimension.ConceptRef.MaintainableReference.MaintainableId;
            this._conceptSchemeAgency = dimension.ConceptRef.MaintainableReference.AgencyId;
            this._conceptSchemeVersion = dimension.ConceptRef.MaintainableReference.Version;

            this._timeDimension = dimension.TimeDimension;
            this._measureDimension = dimension.MeasureDimension;
            this._frequencyDimension = dimension.FrequencyDimension;

            this._names=new List<TextTypeWrapper>();
            this._descriptions=new List<TextTypeWrapper>();
            this._codelistItems=new List<Code>();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Defuzzifies the specified relation returning a crisp value for the specified inputs.
        /// </summary>
        /// <param name="relation">Fuzzy Relation to defuzzify</param>
        /// <param name="inputs">Set of specified values for particular dimensions. There must be exactly one dimesion missing. This dimension will be used as the output dimension.</param>
        public Defuzzification(FuzzyRelation relation, Dictionary<IDimension, System.Decimal> inputs)
        {
            _relation = relation;

            if (inputs.Count < _relation.Dimensions.Length - 1) throw new ArgumentException(String.Format("Number of dimensions must be bigger than n-1, where n={0} is the total number of dimensions used in the relation.", relation.Dimensions.Length), "inputs");

            List<IDimension> dims = _relation.Dimensions.ToList<IDimension>();

            foreach (KeyValuePair<IDimension, System.Decimal> input in inputs)
            {
                //if (!dims.Contains(input.Key))
                //    throw new ArgumentException(String.Format("Dimension \"{0}\" does not exists in this relation.", input.Key), "inputs");

                if (dims.Contains(input.Key))
                    dims.Remove(input.Key);
            }

            if (dims.Count > 1) throw new ArgumentException("There is more than one unspecified dimension left.", "inputs");

            if (dims.Count == 0) throw new ArgumentException("There are no unspecified dimensions left. The output function would be a constanct which can be obtained easier using the IsMember() method.", "inputs");

            _inputs = inputs;
            _outputDimension = dims[0];

            if (_outputDimension is IDiscreteDimension)
                throw new ArgumentException(String.Format("Continuous dimension expected as output dimension. Dimension \"{0}\" is discrete.", _outputDimension.Name));
        }
Ejemplo n.º 4
0
        public XaTableMapper(IDimension dimension, string tableName = null,
            string dimensionTableName = null, bool hashKey = false,
            string keyName = null, string labelName = null, ILabelProvider labelProvider = null,            
            IEnumerable<IFieldMapper> additionalFields = null, FactTypes factTypes = FactTypes.All)
        {
            var defintion = new TableDefinition(tableName);

            Dimension = dimension;

            labelName = labelName ?? dimension.GetType().Name + "Label";            
            
            defintion.FieldMappers.Add(new FieldMapperSet(dimensionTableName, dimensionTableName == null,
                new[]
                {
                    new LabeledFieldMapper(new XaDimensionDataMapper(dimension, !hashKey, keyName), labelName, labelProvider, friendlyName: XaFieldMapper.SuggestFriendlyLabelName(labelName))
                }));

            defintion.FieldMappers.Add(new XaFacts(factTypes: factTypes));

            if (additionalFields != null)
            {
                foreach (var f in additionalFields)
                {
                    defintion.FieldMappers.Add(f);
                }
            }
            
            TableDefinitions.Add(defintion);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates new instance of the TreeSource for the specifed relation
 /// </summary>
 /// <param name="deffuzification">Relation wrapped in a deffuzification. In this case, the hierarchy will also contain information about applied deffuzification.</param>
 public TreeSource(Defuzzification deffuzification)
 {
     _relation = deffuzification.Relation;
     _deffuzification = deffuzification;
     _inputs = deffuzification.Inputs;
     _variableDimension = deffuzification.OutputDimension;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Find the converter functor from source to target
        /// </summary>
        /// <param name="source">Dimension to convert from</param>
        /// <param name="target">Dimension to concert to</param>
        /// <param name="power"></param>
        /// <returns>A functor to convert from source into target</returns>
        public static Func<double, double> From(IDimension source, IDistance target, int power)
        {
            var dispatcher = new VisitorDispatcher("Convert");

            var result = dispatcher.Accept(source.GetType(), new DistanceConverter(), source, target, power);

            return (Func<double, double>)result;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates new instance of image just to display a single-dimensional fuzzy set without any values specified.
 /// </summary>
 /// <param name="singleDimensionalSet">Single-dimensional set to display</param>
 public RelationImage(FuzzySet singleDimensionalSet)
 {
     _inputs = new Dictionary<IDimension, decimal> { };
     _relation = singleDimensionalSet;
     _variableDimension = singleDimensionalSet.Dimensions[0];
     _fullySpecified = false;
     _specifiedMembership = null;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Determines whether two dimensions are equal.
        /// </summary>
        /// <param name="dimension1">Dimension one</param>
        /// <param name="dimension2">Dimension two</param>
        /// <returns>Returns <c>true</c> if powers of all dimension bases are same, otherwise returns <c>false</c>.</returns>
        public static bool CompareDimensions(IDimension dimension1, IDimension dimension2)
        {
            for (int i = 0; i < (int)DimensionBase.NUM_BASE_DIMENSIONS; i++)
                if (dimension1.GetPower((DimensionBase) i) != dimension2.GetPower((DimensionBase) i))
                    return( false );

            return( true );
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates new instance of the TreeSource for the specifed relation
 /// </summary>
 /// <param name="deffuzification">Relation wrapped in a deffuzification. In this case, the hierarchy will also contain information about applied deffuzification.</param>
 public TreeSource(FuzzyFramework.Defuzzification.Defuzzification deffuzification)
 {
     _relation = deffuzification.Relation;
     _deffuzification = deffuzification;
     _inputs = deffuzification.Inputs;
     _variableDimension = deffuzification.OutputDimension;
     treeView_AfterSelect_EventHandler = new TreeViewEventHandler(treeView_AfterSelect);
 }
Ejemplo n.º 10
0
        private BreakByMetric(IDimension subDimension, MetricMultiplexer metricsTemplate)
        {
            if (subDimension == null)
                throw new ArgumentNullException(nameof(subDimension));

            _metricsTemplate = metricsTemplate;
            _subDimension = subDimension;

            _metricAggregates = new FlexiRow<string, IMetric>(((IMetric)_metricsTemplate).CreateNew);
        }
Ejemplo n.º 11
0
        public XaFieldMapper(IDimension dimension,
            bool primaryKey = false,
            string keyName = null, string friendlyName = null)
        {
            Dimension = dimension;

            _keyName = keyName ?? dimension.GetType().Name + "Key";
            _primaryKey = primaryKey;
            _friendlyName = friendlyName ?? SuggestFriendlyKeyName(_keyName);
        }
Ejemplo n.º 12
0
		///<summary>
		/// Check if the current instance equals another instance of this class.
		///</summary>
		///<param name="obj">The instance to compare the current instance with.</param>
		///<returns><code>true</code> if the instances are the same instance or have the same content.</returns>
		public bool Equals(IDimension obj) 
		{
			if (obj == null || GetType() != obj.GetType()) 
			 return false;
			Dimension d = (Dimension) obj;
			for (int i=0;i<(int)DimensionBase.NUM_BASE_DIMENSIONS;i++) 
			{
				if (_count[i]!=d._count[i])
					return false;
			}
			return true;
		}
Ejemplo n.º 13
0
 public static XaLabelProvider FromDimension(IDimension dimension, Language language)
 {
     try
     {
         var keyTransformer = dimension as IDimensionKeyTransformer ??
                              ApiContainer.Repositories.GetDimensionDefinitionService().GetDimensionKeyTransformer(dimension.DimensionId);
         return keyTransformer != null ? new XaLabelProvider(keyTransformer, language) : null;
     }
     catch (Exception ex)
     {
         Log.Error("Error getting dimension key transformer for dimension " + dimension.DimensionId, ex, typeof(XaLabelProvider));
         return null;
     }
 }        
Ejemplo n.º 14
0
        private static IUnit CreateStubUnit(string unit = "", IDimension dimension = null)
        {
            if (dimension == null)
            {
                dimension = Dimsensionless.Instance;
            }
            var stubUnit = new Mock <IUnit>();

            stubUnit.Setup(x => x.Unit).Returns(unit);
            stubUnit.Setup(x => x.ToString()).Returns(unit);
            stubUnit.Setup(x => x.Equals(stubUnit.Object)).Returns(true);
            stubUnit.Setup(x => x.GetHashCode()).Returns(unit.GetHashCode());
            stubUnit.Setup(x => x.Dimension).Returns(dimension);
            return(stubUnit.Object);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DimensionMutableCore"/> class.
 /// </summary>
 /// <param name="objTarget">
 /// The obj target. 
 /// </param>
 public DimensionMutableCore(IDimension objTarget)
     : base(objTarget)
 {
     this._conceptRole = new List<IStructureReference>();
     this._measureDimension = objTarget.MeasureDimension;
     this._frequencyDimension = objTarget.FrequencyDimension;
     this._timeDimension = objTarget.TimeDimension;
     if (objTarget.ConceptRole != null)
     {
         foreach (ICrossReference currentConceptRole in objTarget.ConceptRole)
         {
             this._conceptRole.Add(currentConceptRole.CreateMutableInstance());
         }
     }
 }
 protected override void Context()
 {
     _userSettings             = A.Fake <IPresentationUserSettings>();
     _projectRetriever         = A.Fake <IProjectRetriever>();
     _userSettingsDisplayUnits = A.Fake <DisplayUnitsManager>();
     _projectDisplayUnits      = A.Fake <DisplayUnitsManager>();
     A.CallTo(() => _userSettings.DisplayUnits).Returns(_userSettingsDisplayUnits);
     A.CallTo(() => _projectRetriever.CurrentProject.DisplayUnits).Returns(_projectDisplayUnits);
     sut                    = new DisplayUnitRetriever(_projectRetriever, _userSettings);
     _dimension             = A.Fake <IDimension>();
     _defaultDimensionUnit  = A.Fake <Unit>();
     _dimension.DefaultUnit = _defaultDimensionUnit;
     A.CallTo(() => _userSettingsDisplayUnits.DisplayUnitFor(_dimension)).Returns(_userSettingsUnit);
     A.CallTo(() => _projectDisplayUnits.DisplayUnitFor(_dimension)).Returns(_projectSettingsUnit);
 }
Ejemplo n.º 17
0
        private static QuantityValues createArray(string path, IDimension dimension, int numberOfPoints)
        {
            var quantityValues = new QuantityValues();

            quantityValues.ColumnId     = ShortGuid.NewGuid();
            quantityValues.QuantityPath = path;
            var values = new float[numberOfPoints];

            for (int i = 0; i < values.Length; i++)
            {
                values[i] = (float)(_random.NextDouble() * 100);
            }
            quantityValues.Values = values;
            return(quantityValues);
        }
Ejemplo n.º 18
0
        public DataColumn(string id, string name, IDimension dimension, BaseGrid baseGrid)
        {
            Id           = id;
            Name         = name;
            Dimension    = dimension;
            BaseGrid     = baseGrid;
            QuantityInfo = new QuantityInfo(new List <string>(), QuantityType.Undefined);
            var defaultUnitName = dimension != null ? dimension.DefaultUnitName : string.Empty;

            DataInfo = new DataInfo(ColumnOrigins.Undefined)
            {
                DisplayUnitName = defaultUnitName
            };
            IsInternal = false;
        }
Ejemplo n.º 19
0
        public void Multiply_AoverBxB_ReturnsA()
        {
            // Arrange
            IDimension        a    = CreateStubDimension("a");
            IDimension        b    = CreateStubDimension("b");
            CompoundDimension unit = new CompoundDimension(a);

            unit = (CompoundDimension)unit.Divide(b);

            // Act
            IDimension result = unit.Multiply(b);

            // Assert
            Assert.AreSame(a, result);
        }
Ejemplo n.º 20
0
        public void MultiplyWithDimension_AmassxBlength_DimensionIsMassLength()
        {
            // Arrange
            IDimension mass   = CreateStubDimension("M");
            IDimension length = CreateStubDimension("L");
            IUnit      a      = CreateStubUnit("a", mass);
            IUnit      b      = CreateStubUnit("b", length);

            // Act
            IUnit      axb       = UnitCombiner.Multiply(a, b);
            IDimension dimension = axb.Dimension;

            // Assert
            Assert.AreEqual(new CompoundDimension(mass).Multiply(length), dimension);
        }
Ejemplo n.º 21
0
        public void Multiply_AxBsquared_EqualsAxAxBxB()
        {
            // Arrange
            IDimension        a    = CreateStubDimension("a");
            IDimension        b    = CreateStubDimension("b");
            CompoundDimension unit = new CompoundDimension(a);
            CompoundDimension axb  = (CompoundDimension)unit.Multiply(b);

            // Act
            IDimension axbsquared = axb.Multiply(axb);
            IDimension axaxbxb    = unit.Multiply(a, b, b);

            // Assert
            Assert.AreEqual(axaxbxb, axbsquared);
        }
Ejemplo n.º 22
0
        protected override void Context()
        {
            base.Context();
            _dimension           = DimensionFactoryForSpecs.Factory.Dimension(DimensionFactoryForSpecs.DimensionNames.Mass);
            _parameterStartValue = A.Fake <IParameterStartValue>();
            _parameter           = new Parameter {
                Dimension = _dimension, Name = _name, Value = 1.0
            };

            A.CallTo(() => _parameterStartValue.Dimension).Returns(_dimension);
            A.CallTo(() => _parameterStartValue.Name).Returns(_name);
            A.CallTo(() => _parameterStartValue.Formula).Returns(null);
            A.CallTo(() => _parameterStartValue.StartValue).Returns(1.0);
            A.CallTo(() => _parameterStartValue.DisplayUnit).Returns(_parameter.DisplayUnit);
        }
Ejemplo n.º 23
0
        public void AddUnit_DimensionMismatch_ThrowsArgumentException()
        {
            // Arrange
            var                mockDelegate = new Mock <ICreateAdjacentValueConverterDelegateFunctor>();
            IDimension         mass         = CreateStubDimension("M");
            IDimension         length       = CreateStubDimension("L");
            IUnit              kg           = CreateStubUnit("kg", mass);
            IUnit              m            = CreateStubUnit("m", length);
            DimensionContainer container    = new DimensionContainer(mass, mockDelegate.Object.Create);

            container.SetBaseUnit(kg);

            // Act/Assert
            Assert.Throws <ArgumentException>(() => container.AddUnit(kg, m));
        }
        protected DataPanelBase(IDimension cbcol, IDimension cbrow)
        {
            cb_col = cbcol;
            cb_row = cbrow;

            cb_row.changed += (object sender, int e) => {
                // TODO if we were caching edges/lengths, invalidate the cache here
                SetNeedsRedraw();
            };

            cb_col.changed += (object sender, int e) => {
                // TODO if we were caching edges/lengths, invalidate the cache here
                SetNeedsRedraw();
            };
        }
        public override void UpdatePropertiesFrom(IUpdatable source, ICloneManager cloneManager)
        {
            base.UpdatePropertiesFrom(source, cloneManager);

            var srcAppMoleculeBuilder = source as IApplicationMoleculeBuilder;

            if (srcAppMoleculeBuilder == null)
            {
                return;
            }

            RelativeContainerPath = srcAppMoleculeBuilder.RelativeContainerPath.Clone <IObjectPath>();
            Formula   = cloneManager.Clone(srcAppMoleculeBuilder.Formula);
            Dimension = srcAppMoleculeBuilder.Dimension;
        }
        protected override void Context()
        {
            _baseGrid           = new BaseGrid("base", "Time", DomainHelperForSpecs.TimeDimensionForSpecs());
            _column             = new DataColumn("col", "name", DomainHelperForSpecs.ConcentrationDimensionForSpecs(), _baseGrid);
            _molWeightDimension = DomainHelperForSpecs.LengthDimensionForSpecs();
            _observedData       = new DataRepository(_id)
            {
                _column
            };
            _newValue = 100;
            _oldValue = 50;
            sut       = new UpdateObservedDataMolWeightCommand(_observedData, _molWeightDimension, _oldValue, _newValue);

            _executionContext = A.Fake <IOSPSuiteExecutionContext>();
        }
Ejemplo n.º 27
0
        private DisplayUnitMap retrieveDisplayUnitMapFor(IDimension dimension)
        {
            var mergedDimension = dimension as IMergedDimension;

            if (mergedDimension == null)
            {
                return(_allDisplayUnits.Find(x => Equals(x.Dimension, dimension)));
            }

            var allDimensions = new List <IDimension>(mergedDimension.TargetDimensions);

            allDimensions.Insert(0, mergedDimension.SourceDimension);

            return(allDimensions.Select(retrieveDisplayUnitMapFor).FirstOrDefault(x => x != null));
        }
 public EditTableFormulaWithOffsetFormulaPresenter(
     IEditTableFormulaWithOffsetFormulaView view,
     ITableFormulaWithOffsetToTableFormulaWithOffsetDTOMapper mapper,
     IMoBiContext context,
     IMoBiFormulaTask moBiFormulaTask,
     IDisplayUnitRetriever displayUnitRetriever,
     IApplicationController applicationController,
     ISelectReferencePresenterFactory selectReferencePresenterFactory) : base(view, displayUnitRetriever)
 {
     _mapper                          = mapper;
     _moBiFormulaTask                 = moBiFormulaTask;
     _applicationController           = applicationController;
     _selectReferencePresenterFactory = selectReferencePresenterFactory;
     _timeDimension                   = context.DimensionFactory.Dimension(Constants.Dimension.TIME);
 }
Ejemplo n.º 29
0
 ///<summary>
 /// Check if the current instance equals another instance of this class.
 ///</summary>
 ///<param name="dim1">The instance to compare the current instance with.</param>
 ///<returns><code>true</code> if the instances are the same instance or have the same content.</returns>
 public static bool DescribesSameAs(IDimension dim1, IDimension dim2)
 {
     if (dim1 == null || dim2 == null)
     {
         return(false);
     }
     foreach (DimensionBase dimBase in Enum.GetValues(typeof(DimensionBase)))
     {
         if (dim1.GetPower(dimBase) != dim2.GetPower(dimBase))
         {
             return(false);
         }
     }
     return(true);
 }
            public void Dispose()
            {
                if (Marshal.IsComObject(Dimension))
                {
                    Marshal.ReleaseComObject(Dimension);
                }

                if (Marshal.IsComObject(DisplayDimension))
                {
                    Marshal.ReleaseComObject(DisplayDimension);
                }

                Dimension        = null;
                DisplayDimension = null;
            }
 public AmountToConcentrationConverter(IReactionDimensionRetriever reactionDimensionRetriever,
                                       IDimensionFactory dimensionFactory, IAmoutToConcentrationFormulaMapper amoutToConcentrationFormulaMapper,
                                       IObjectBaseFactory objectBaseFactory, IFormulaTask formulaTask, IDisplayUnitRetriever displayUnitRetriever,
                                       IObjectTypeResolver objectTypeResolver, IFormulaFactory formulaFactory)
 {
     _reactionDimensionRetriever        = reactionDimensionRetriever;
     _amoutToConcentrationFormulaMapper = amoutToConcentrationFormulaMapper;
     _objectBaseFactory             = objectBaseFactory;
     _formulaTask                   = formulaTask;
     _displayUnitRetriever          = displayUnitRetriever;
     _objectTypeResolver            = objectTypeResolver;
     _formulaFactory                = formulaFactory;
     _concentrationDimension        = dimensionFactory.Dimension(Constants.Dimension.MOLAR_CONCENTRATION);
     _concentrationPerTimeDimension = dimensionFactory.Dimension(Constants.Dimension.MOLAR_CONCENTRATION_PER_TIME);
 }
Ejemplo n.º 32
0
 public void SelectDimension(string dimensionName)
 {
     this.DoWithinExceptionHandler(() =>
     {
         Dimension = _dimensions.FirstOrDefault(d => string.Equals(d.Name, dimensionName)) ??
                     _dimensions.FirstOrDefault() ??
                     Constants.Dimension.NO_DIMENSION;
         //checking whether _selectedUnit is not supported by the current dimension, meaning that the user
         //has selected a new dimension and the unit must be reset to the default unit of this dimension
         if (_view.SelectedUnit == null || !Dimension.HasUnit(_view.SelectedUnit))
         {
             fillUnits(Dimension.DefaultUnitName);
         }
     });
 }
Ejemplo n.º 33
0
        protected override void Context()
        {
            _buildingBlock = new ObserverBuildingBlock();
            _context       = A.Fake <IMoBiContext>();
            _newDimension  = DimensionFactoryForSpecs.Factory.Dimension(DimensionFactoryForSpecs.DimensionNames.Mass);
            _oldDimension  = DimensionFactoryForSpecs.Factory.Dimension(DimensionFactoryForSpecs.DimensionNames.Concentration);

            _observedBuilder = new ObserverBuilder
            {
                Dimension = _oldDimension,
                Formula   = new ConstantFormula(5).WithDimension(_oldDimension)
            }.WithId("5");

            sut = new UpdateDimensionInObserverBuilderCommand(_observedBuilder, _newDimension, _buildingBlock);
        }
Ejemplo n.º 34
0
            protected override void Given()
            {
                const int areaDimensionX     = 100;
                const int areaDimensionY     = 100;
                const int platformDimensionX = 50;
                const int platformDimensionY = 50;

                _areaDimension = new Dimension(areaDimensionX, areaDimensionY);

                var landingStrategy   = Mock.Of <ILandingStrategy>();
                var platformDimension = new Dimension(platformDimensionX, platformDimensionY);

                _platform = new LandingPlatform(platformDimension, landingStrategy);

                _approachCheckResultMapper = Mock.Of <IApproachCheckResultMapper>();
            }
        protected override void Context()
        {
            _time = DomainHelperForSpecs.TimeDimensionForSpecs();
            _mass = new Dimension(new BaseDimensionRepresentation {
                MassExponent = 1
            }, "Mass", "kg");
            _mass.AddUnit("mg", 0.1, 0.0);
            _mass.DefaultUnit = _mass.Unit("mg");

            _baseGrid1 = new BaseGrid("BaseGrid1", _time)
            {
                Values = new float[] { 1, 2, 3 }
            };
            _dataRepository = new DataRepository("id").WithName("toto");
            sut             = new DataRepositoryExportTask();;
        }
Ejemplo n.º 36
0
        public static DataRepository ObservedData(string id = "TestData", IDimension timeDimension = null, IDimension concentrationDimension = null, string obsDataColumnName = null)
        {
            var observedData = new DataRepository(id).WithName(id);
            var baseGrid     = new BaseGrid("Time", timeDimension ?? TimeDimensionForSpecs())
            {
                Values = new[] { 1.0f, 2.0f, 3.0f }
            };

            observedData.Add(baseGrid);

            var data = ConcentrationColumnForObservedData(baseGrid, concentrationDimension, obsDataColumnName);

            observedData.Add(data);

            return(observedData);
        }
        protected override void Context()
        {
            _buildingBlock = A.Fake <IBuildingBlock>();
            _alias         = "alias";
            _formula       = new ExplicitFormula("string");
            _formula.AddObjectPath(new FormulaUsablePath {
                Alias = _alias, Dimension = DomainHelperForSpecs.AmountDimension
            });
            _newDimension = DomainHelperForSpecs.ConcentrationDimension;
            _context      = A.Fake <IMoBiContext>();
            A.CallTo(() => _context.Get <IFormula>(_formula.Id)).Returns(_formula);
            A.CallTo(() => _context.DimensionFactory.Dimension(_newDimension.ToString())).Returns(_newDimension);
            A.CallTo(() => _context.DimensionFactory.Dimension(DomainHelperForSpecs.AmountDimension.ToString())).Returns(DomainHelperForSpecs.AmountDimension);

            sut = new UpdateDimensionOfFormulaUsablePathCommand(_newDimension, _formula, _alias, _buildingBlock);
        }
Ejemplo n.º 38
0
        protected override void Context()
        {
            base.Context();
            _buildingBlockToAddTo = A.Fake <IBuildingBlock>();
            _formulaCache         = new FormulaCache();
            A.CallTo(() => _buildingBlockToAddTo.FormulaCache).Returns(_formulaCache);

            _totalyNewObject        = new Parameter().WithName("New");
            _theDimension           = A.Fake <IDimension>();
            _oldFormula             = A.Fake <ExplicitFormula>().WithName("New Formula").WithDimension(_theDimension).WithFormulaString("1+1").WithId("1");
            _newFormula             = A.Fake <ExplicitFormula>().WithName("New Formula_2").WithDimension(_theDimension).WithFormulaString("1+1").WithId("1");
            _newFormula.ObjectPaths = new IFormulaUsablePath[0];
            _oldFormula.ObjectPaths = new IFormulaUsablePath[0];
            _formulaCache.Add(_oldFormula);
            _totalyNewObject.Formula = _newFormula;
        }
Ejemplo n.º 39
0
        protected override void Context()
        {
            _executionContext = A.Fake <IExecutionContext>();
            _favoriteTask     = A.Fake <IFavoriteTask>();
            _project          = A.Fake <IProject>();
            sut = new ParameterTask(new EntityPathResolver(new ObjectPathFactoryForSpecs()), _executionContext, _favoriteTask);
            var dimensionFactory = new DimensionFactory();

            _volumeDimension = dimensionFactory.AddDimension(new BaseDimensionRepresentation {
                LengthExponent = 3
            }, "Volume", "L");
            _volumeDimension.AddUnit("mL", 1e-3, 0);
            _parameter           = DomainHelperForSpecs.ConstantParameterWithValue(10);
            _parameter.Dimension = _volumeDimension;
            A.CallTo(() => _executionContext.BuildingBlockContaining(_parameter)).Returns(A.Fake <IPKSimBuildingBlock>());
        }
Ejemplo n.º 40
0
        public override void UpdatePropertiesFrom(IUpdatable source, ICloneManager cloneManager)
        {
            base.UpdatePropertiesFrom(source, cloneManager);

            var srcEventAssignmentBuilder = source as IEventAssignmentBuilder;

            if (srcEventAssignmentBuilder == null)
            {
                return;
            }

            UseAsValue = srcEventAssignmentBuilder.UseAsValue;
            Dimension  = srcEventAssignmentBuilder.Dimension;

            ObjectPath = srcEventAssignmentBuilder.ObjectPath.Clone <IObjectPath>();
        }
Ejemplo n.º 41
0
        protected override void Context()
        {
            _fakeDimension = A.Fake <IDimension>();
            _context       = A.Fake <IMoBiContext>();
            _buildingBlock = new MoleculeStartValuesBuildingBlock();

            var msv = new MoleculeStartValue {
                Path = new ObjectPath("path1"), Dimension = _fakeDimension, StartValue = -1, DisplayUnit = new Unit("Dimensionless", 1.0, 1), IsPresent = false
            };

            _buildingBlock.Add(msv);
            _path = msv.Path;

            sut = new UpdateMoleculeStartValueInBuildingBlockCommand(_buildingBlock, _path, 1.0, true, 22.0, true);
            A.CallTo(() => _context.Get <IMoleculeStartValuesBuildingBlock>(_buildingBlock.Id)).Returns(_buildingBlock);
        }
Ejemplo n.º 42
0
        private static string getUnit(IDimension dimension)
        {
            if (dimension == null)
            {
                return(" DIMENSION IS NULL!");
            }

            string unit = dimension.BaseUnit.Name;

            if (!string.IsNullOrEmpty(unit))
            {
                unit = $" [{unit}]";
            }

            return(unit);
        }
Ejemplo n.º 43
0
 protected override void Context()
 {
     _mw                        = 10;
     _column                    = A.Fake <DataColumn>();
     _column.Dimension          = _source;
     _column.DataInfo           = A.Fake <DataInfo>();
     _column.DataInfo.MolWeight = _mw;
     _source                    = new Dimension(new BaseDimensionRepresentation(), "DrugMass", "g");
     _source.AddUnit("mg", 1000, 0);
     _source.DefaultUnit = _source.Unit("mg");
     _target             = new Dimension(new BaseDimensionRepresentation(), "Target", "mol");
     _target.AddUnit("mmol", 300, 0);
     _target.DefaultUnit = _target.Unit("mmol");
     sut = new ConcentrationToMolarConcentrationConverterForDataColumn(_source, _target);
     sut.SetRefObject(_column);
 }
 public CKDDiseaseStateImplementation(
     IValueOriginRepository valueOriginRepository,
     IDimensionRepository dimensionRepository,
     IFormulaFactory formulaFactory,
     IIndividualFactory individualFactory,
     IContainerTask containerTask,
     IParameterSetUpdater parameterSetUpdater)
 {
     _valueOriginRepository = valueOriginRepository;
     _formulaFactory        = formulaFactory;
     _individualFactory     = individualFactory;
     _containerTask         = containerTask;
     _parameterSetUpdater   = parameterSetUpdater;
     _dimensionForGFR       = dimensionRepository.DimensionForUnit(GFR_UNIT);
     _ageDimension          = dimensionRepository.AgeInYears;
 }
Ejemplo n.º 45
0
		public DimensionObjectBaseCore(IDimension dimension,
				ICodelistObjectBase codeList, IConceptObjectBase concept,
				ISet<IHierarchicalCodelistObjectBase> hcls0) : base(dimension, codeList, concept) {
			this._dimension = dimension;
			this._isFrequenyDimension = dimension.FrequencyDimension;
			this._isMeasureDimension = dimension.MeasureDimension;
			this._isTimeDimension = dimension.TimeDimension;
	
			this._hcls = hcls0;
			if (hcls0 == null) {
				this._hcls = new HashSet<IHierarchicalCodelistObjectBase>();
			}
			if (concept == null) {
				throw new ModelException(Org.Sdmxsource.Sdmx.Api.Constants.ExceptionCode.JavaRequiredObjectNull,
						typeof(IConceptObjectBase).FullName);
			}
		}
Ejemplo n.º 46
0
        /// <summary>
        /// Creates new instance of image depicting the specified relation.
        /// </summary>
        /// <param name="relation">Relation to draw</param>
        /// <param name="inputs">Set of specified values for particular dimensions. There can be one dimesion missing. This dimension will be used as the variable dimension on the X-axis. If all dimensions specified, variable dimension needs to be specifed as explicit parameter</param>
        public RelationImage(FuzzyRelation relation, Dictionary<IDimension, System.Decimal> inputs, IDimension variableDimension)
        {
            _relation = relation;

            if (inputs.Count < _relation.Dimensions.Length - 1) throw new ArgumentException(String.Format("Number of dimensions must at least n-1, where n={0} is the total number of dimensions used in the relation.", relation.Dimensions.Length), "inputs");

            List<IDimension> dims = _relation.Dimensions.ToList<IDimension>();

            foreach (KeyValuePair<IDimension, System.Decimal> input in inputs)
            {
                //if (!dims.Contains(input.Key))
                //    throw new ArgumentException(String.Format("Dimension \"{0}\" does not exists in this relation.", input.Key), "inputs");

                if (dims.Contains(input.Key))
                    dims.Remove(input.Key);
            }

            if (dims.Count > 1) throw new ArgumentException("There is more than one unspecified dimension left.", "inputs");

            _inputs = inputs;

            if (dims.Count == 1)
            {
                _variableDimension = dims[0];
                if (variableDimension != null && variableDimension != _variableDimension)
                    throw new ArgumentException("Variable dimension missing in inputs does not match the dimension specified by parameter variableDimension.", "variableDimension");
                _fullySpecified = false;
            }
            else
            {
                if (variableDimension == null)
                    throw new ArgumentException("Variable dimension has to be defined explicitly if all variables specified in parameter inputs.", "variableDimension");
                _variableDimension = variableDimension;
                _fullySpecified = true;
                _specifiedValue =  new decimal?(_inputs[_variableDimension]);
                _specifiedMembership = new Nullable<double>( this.isMember(_specifiedValue.Value) );
            }
        }
Ejemplo n.º 47
0
        private string GetDimensionRole(IDimension dimension)
        {
            string ret = "Dimension";

            if (dimension.TimeDimension)
                ret = "TimeDimension";

            if (dimension.FrequencyDimension)
                ret = "FrequencyDimension";

            if (dimension.MeasureDimension)
                ret = "MeasureDimension";

            return ret;
        }
Ejemplo n.º 48
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public override bool Equals(IDimension other)
 {
     return Equals(this, other);
 }
Ejemplo n.º 49
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="unit"></param>
 /// <returns></returns>
 public IDerivedDimension Replace(IDimension unit)
 {
     TryReplace(unit);
     return this;
 }
        static Quantity GetQuantity(IDescribable describes, IDimension iDimension, int dimension)
        {
            ValueDefinition vd;

            switch (dimension)
            {
                case 1:
                    vd = new ValueDefinition(describes,
                        typeof(double),
                        Double.NegativeInfinity);
                    break;
                case 2:
                    vd = new ValueDefinition(describes,
                        typeof(Vector2d<double>),
                        new Vector2d<double>(Double.NegativeInfinity));
                    break;
                case 3:
                    vd = new ValueDefinition(describes,
                        typeof(Vector3d<double>),
                        new Vector3d<double>(Double.NegativeInfinity));
                    break;
                default:
                    throw new NotImplementedException(dimension.ToString());
            }

            var unit = new Unit(describes, iDimension);

            return new Quantity(vd, unit);
        }
Ejemplo n.º 51
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="unit"></param>
        /// <returns></returns>
        public bool TryReplace(IDimension unit)
        {
            var result = true;

            for (var i = 0; i < _dimensions.Count; i++)
            {
                var d = _dimensions[i];

                {
                    /* If this level of derivation did not have the unit then perhaps any of the
                     * contained derivations does. Replaces the first such occurrence. */

                    var derived = d as IDerivedDimension;

                    if (derived != null)
                    {
                        result = result && derived.TryReplace(unit);
                        continue;
                    }
                }

                if (d.DimensionId != unit.DimensionId) continue;

                var replacing = _dimensions[i] = (IDimension) d.Clone();

                replacing.Exponent = d.Exponent;
            }

            return result;
        }
Ejemplo n.º 52
0
 private static bool Equals(IDerivedDimension a, IDimension b)
 {
     return !(a == null || b == null)
            && a.IsDimensionEquals(b)
            && a.AreEquivalent(b as IDerivedDimension)
            && a.Exponent == b.Exponent;
 }
        /// <summary>
        /// The compare to.
        /// </summary>
        /// <param name="other">
        /// The other. 
        /// </param>
        /// <returns>
        /// The <see cref="int"/> . 
        /// </returns>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public virtual int CompareTo(IDimension other)
        {
            if (other.Position == this.Position)
            {
                if (!other.Equals(this))
                {
                    throw new SdmxSemmanticException(
                        "Two dimensions (" + this.Id + " & " + other.Id + ") can not share the same dimension position : "
                        + this.Position);
                }
            }

            return (other.Position > this.Position) ? -1 : +1;
        }
        private static void VerifyAngular(this IQuantity quantity)
        {
            quantity.VerifyNotNull();

            IEnumerable<IDimension[]> expected = new IDimension[][]
            {
                new[] {SiTheta.Radian},
                new[] {UsTheta.Degree}
            };

            if (expected.Any(x => quantity.Dimensions.AreEquivalent(x)))
                return;

            var message = string.Format("Unable to perfom function on quantity {{{0}}}.", quantity);
            throw new IncompatibleDimensionsException(message, quantity);
        }
Ejemplo n.º 55
0
		///<summary>
		/// Check if the current instance equals another instance of this class.
		///</summary>
		///<param name="dim1">The instance to compare the current instance with.</param>
		///<returns><code>true</code> if the instances are the same instance or have the same content.</returns>
        public static bool DescribesSameAs(IDimension dim1, IDimension dim2) 
		{
            if (dim1 == null || dim2 == null) 
			 return false;
		    foreach (DimensionBase dimBase in Enum.GetValues(typeof(DimensionBase)))
		    {
                if (dim1.GetPower(dimBase) != dim2.GetPower(dimBase))
                    return false;
		    }
			return true;
		}
Ejemplo n.º 56
0
 /// <summary>
 /// Creates new instance of the TreeSource for the specifed relation
 /// </summary>
 /// <param name="relation">Fuzzy relation to represent as a hierarchical list</param>
 /// <param name="inputs">Set of specified values for particular dimensions.</param>
 /// <param name="variableDimension">Dimension which should be put on the x-axis</param>
 public TreeSource(FuzzyRelation relation, Dictionary<IDimension, System.Decimal> inputs, IDimension variableDimension)
 {
     _relation = relation;
     _inputs = inputs;
     _variableDimension = variableDimension;
 }
Ejemplo n.º 57
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="unit">Unit</param>
		/// <param name="Description">Description</param>
		/// <param name="ID">ID</param>
		/// <param name="valueType">Value type (vector or scalar)</param>
		/// <param name="Dimension">Dimension</param>
		public Quantity(IUnit unit, string Description, string ID,ValueType valueType,
			IDimension Dimension)
		{
			_unit = unit;
			_description = Description;
			_id = ID;
			_valueType = valueType;
			_dimension = Dimension;
		}
 static Quantity GetQuantity(IDescribable describes, IDimension iDimension)
 {
     return GetQuantity(describes, iDimension, 1);
 }
Ejemplo n.º 59
0
 public Unit(string name, string symbol, IDimension dimension)
 {
     this.name = name;
     this.symbol = symbol;
     this.dimension = dimension;
 }
Ejemplo n.º 60
0
		private bool CompareDimensions(IDimension dimension1, IDimension dimension2)
		{
			bool isSameDimension = true;

			for (int i = 0; i < (int)DimensionBase.NUM_BASE_DIMENSIONS; i++)
			{
				if (dimension1.GetPower((DimensionBase) i) != dimension2.GetPower((DimensionBase) i))
				{
					isSameDimension = false;
				}
			}
			return isSameDimension;
		}