//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSingleValue()
        public virtual void testSingleValue()
        {
            double value = 3.0;

            double[] x = new double[] { value };
            assertEquals(value, MEAN.apply(x), EPS);
            assertEquals(value, MEDIAN.apply(x), EPS);
            assertEquals(value, MODE.apply(x), EPS);
        }
 //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
 //ORIGINAL LINE: @Test public void test()
 public virtual void test()
 {
     double x;
     const double eps = 1e-5;
     for (int i = 0; i < 100; i++)
     {
       x = RANDOM.NextDouble();
       assertEquals(x, F.apply(T.getCDF(x)), eps);
     }
 }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void detects_duplicate_procedure_with_default_names()
        public virtual void DetectsDuplicateProcedureWithDefaultNames()
        {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            Element procedureA = ProcedureMethod(typeof(DefaultProcedureA).FullName);
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            Element procedureB = ProcedureMethod(typeof(DefaultProcedureB).FullName);
            ICollection <Element> duplicates = asList(procedureA, procedureB);

            Stream <CompilationMessage> errors = _validator.apply(duplicates);

            string procedureName = "org.neo4j.tooling.procedure.validators.examples.procedure";

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat(errors).extracting(CompilationMessage::getCategory, CompilationMessage::getElement, CompilationMessage::getContents).containsExactlyInAnyOrder(tuple(Diagnostic.Kind.ERROR, procedureA, "Procedure|function name <" + procedureName + "> is already defined 2 times. It should be defined " + "only once!"), tuple(Diagnostic.Kind.ERROR, procedureB, "Procedure|function name <" + procedureName + "> is already defined 2 times. It should be defined only once!"));
        }
Esempio n. 4
0
        public override double?apply(double[] x)
        {
            ArgChecker.notNull(x, "x");
            int n = x.Length;

            ArgChecker.isTrue(n >= 2, "Need at least two points to calculate the population variance");
            return(_variance.apply(x) * (n - 1) / n);
        }
Esempio n. 5
0
 /// <summary>
 /// Builds the object given type. Can only be called if <seealso cref="isComplete()"/> is true. </summary>
 /// <returns> the complete object </returns>
 /// <exception cref="IllegalStateException"> if <seealso cref="isComplete()"/> is false. </exception>
 public virtual CONTENT Build()
 {
     if (!_isComplete)
     {
         throw new System.InvalidOperationException("Cannot build unfinished content");
     }
     return(_contentFunction.apply(null));
 }
            public override DoubleArray apply(DoubleArray s)
            {
                double shift       = s.get(0);
                Curve  curveBumped = ParallelShiftedCurve.absolute(curve, shift);
                CurrencyParameterSensitivity pts = sensitivitiesFn.apply(curveBumped);

                return(pts.Sensitivity);
            }
Esempio n. 7
0
            public override CsvRotatableWriter Apply(File file)
            {
                RotatingFileOutputStreamSupplier outputStreamSupplier = FileSupplierStreamCreator.apply(file, new HeaderWriterRotationListener(this));
                PrintWriter        printWriter = CreateWriter(outputStreamSupplier.Get());
                CsvRotatableWriter writer      = new CsvRotatableWriter(printWriter, outputStreamSupplier);

                WriteHeader(printWriter, Header);
                return(writer);
            }
Esempio n. 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void test()
        public virtual void test()
        {
            DoubleMatrix m1 = ESTIMATE.getInitializedMatrix(J, X);
            DoubleMatrix m2 = J.apply(X);

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    assertEquals(m1.get(i, j), m2.get(i, j), 1e-9);
                }
            }
        }
Esempio n. 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBuildMemberAttributedWithSpecifiedDBNames() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBuildMemberAttributedWithSpecifiedDBNames()
        {
            //given
            int              numMembers       = 10;
            ISet <Member>    hazelcastMembers = new HashSet <Member>();
            IList <MemberId> coreMembers      = new List <MemberId>();

            IDictionary <int, string> dbNames = CausalClusteringTestHelpers.distributeDatabaseNamesToHostNums(numMembers, _dbNames);

            System.Func <int, Dictionary <string, string> > generator = i =>
            {
                Dictionary <string, string> settings = _defaultSettingsGenerator.apply(i);
                settings.put(CausalClusteringSettings.database.name(), dbNames[i]);
                return(settings);
            };

            IList <Config> configs = GenerateConfigs(numMembers, generator);

            for (int i = 0; i < configs.Count; i++)
            {
                MemberId mId = new MemberId(System.Guid.randomUUID());
                coreMembers.Add(mId);

                Config c = configs[i];
                IDictionary <string, object> attributes = buildMemberAttributesForCore(mId, c).Attributes;
                hazelcastMembers.Add(new MemberImpl(new Address("localhost", i), null, attributes, false));
            }

            // when
            IDictionary <MemberId, CoreServerInfo> coreMemberMap = toCoreMemberMap(hazelcastMembers, NullLog.Instance, _hzInstance);

            // then
            for (int i = 0; i < numMembers; i++)
            {
                CoreServerInfo coreServerInfo = coreMemberMap[coreMembers[i]];
                string         expectedDBName = dbNames[i];
                assertEquals(expectedDBName, coreServerInfo.DatabaseName);
            }
        }
Esempio n. 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStoreAndLoadStrings()
        public virtual void ShouldStoreAndLoadStrings()
        {
            // given
            using (StringCollisionValues values = new StringCollisionValues(Factory.apply(Storage), 10_000))
            {
                // when
                long[]   offsets = new long[100];
                string[] strings = new string[offsets.Length];
                for (int i = 0; i < offsets.Length; i++)
                {
                    string @string = random.nextAlphaNumericString();
                    offsets[i] = values.Add(@string);
                    strings[i] = @string;
                }

                // then
                for (int i = 0; i < offsets.Length; i++)
                {
                    assertEquals(strings[i], values.Get(offsets[i]));
                }
            }
        }
        public virtual void test()
        {
            DoubleMatrix m1       = ESTIMATE.getInitializedMatrix(J, X);
            DoubleMatrix m2       = J.apply(X);
            DoubleMatrix m3       = (DoubleMatrix)(ALGEBRA.multiply(m1, m2));
            DoubleMatrix identity = DoubleMatrix.identity(2);

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    assertEquals(m3.get(i, j), identity.get(i, j), 1e-6);
                }
            }
        }
Esempio n. 12
0
        public override double?apply(double[] x)
        {
            ArgChecker.notNull(x, "x");
            ArgChecker.isTrue(x.Length >= 2, "Need at least two points to calculate the sample variance");
            double?mean = MEAN.apply(x);
            double sum  = 0;

            foreach (double value in x)
            {
                double diff = value - mean;
                sum += diff * diff;
            }
            int n = x.Length;

            return(sum / (n - 1));
        }
Esempio n. 13
0
        public virtual void test_zValue()
        {
            double                   tol            = 1.0e-14;
            double                   x              = 2.5;
            double                   y              = 1.44;
            DeformedSurface          test           = DeformedSurface.of(METADATA, SURFACE_ORG, FUNCTION);
            double                   computedValue1 = test.zValue(x, y);
            double                   computedValue2 = test.zValue(DoublesPair.of(x, y));
            UnitParameterSensitivity computedSensi1 = test.zValueParameterSensitivity(x, y);
            UnitParameterSensitivity computedSensi2 = test.zValueParameterSensitivity(DoublesPair.of(x, y));
            ValueDerivatives         expected       = FUNCTION.apply(DoublesPair.of(x, y));

            assertEquals(computedValue1, expected.Value);
            assertEquals(computedValue2, expected.Value);
            assertTrue(DoubleArrayMath.fuzzyEquals(computedSensi1.Sensitivity.toArray(), expected.Derivatives.toArray(), tol));
            assertTrue(DoubleArrayMath.fuzzyEquals(computedSensi2.Sensitivity.toArray(), expected.Derivatives.toArray(), tol));
        }
Esempio n. 14
0
 public override bool Next()
 {
     try
     {
         while ((_terms.next()) != null)
         {
             if (_client.acceptNode(_terms.docFreq(), _valueMaterializer.apply(_terms.term())))
             {
                 return(true);
             }
         }
         return(false);
     }
     catch (IOException e)
     {
         throw new UncheckedIOException(e);
     }
 }
Esempio n. 15
0
        public override void EndOfEntity()
        {
            if (_relationshipRecord.inUse() && _relationshipRecord.FirstNode != ID_NOT_FOUND && _relationshipRecord.SecondNode != ID_NOT_FOUND && _relationshipRecord.Type != -1)
            {
                _relationshipRecord.Id = _relationshipIds.next();
                if (_doubleRecordUnits)
                {
                    // simply reserve one id for this relationship to grow during linking stage
                    _relationshipIds.next();
                }
                _relationshipRecord.NextProp           = CreateAndWritePropertyChain();
                _relationshipRecord.FirstInFirstChain  = false;
                _relationshipRecord.FirstInSecondChain = false;
                _relationshipRecord.FirstPrevRel       = Record.NO_NEXT_RELATIONSHIP.intValue();
                _relationshipRecord.SecondPrevRel      = Record.NO_NEXT_RELATIONSHIP.intValue();
                _relationshipStore.prepareForCommit(_relationshipRecord, _prepareIdSequence.apply(_relationshipRecord.Id));
                _relationshipStore.updateRecord(_relationshipRecord);
                _relationshipCount++;
                _typeCounts.increment(_relationshipRecord.Type);
            }
            else
            {
                if (_validateRelationshipData)
                {
                    ValidateNode(_startId, Type.START_ID);
                    ValidateNode(_endId, Type.END_ID);
                    if (_relationshipRecord.Type == -1)
                    {
                        throw new MissingRelationshipDataException(Type.TYPE, RelationshipDataString() + " is missing " + Type.TYPE + " field");
                    }
                }
                _badCollector.collectBadRelationship(_startId, Group(_startIdGroup).name(), _type, _endId, Group(_endIdGroup).name(), _relationshipRecord.FirstNode == ID_NOT_FOUND ? _startId : _endId);
                EntityPropertyCount = 0;
            }

            _relationshipRecord.clear();
            _relationshipRecord.InUse = true;
            _startId      = null;
            _startIdGroup = null;
            _endId        = null;
            _endIdGroup   = null;
            _type         = null;
            base.EndOfEntity();
        }
Esempio n. 16
0
 private void GatherNonRecordStores(ICollection <StoreFileMetadata> files, bool includeLogs)
 {
     File[] indexFiles = _databaseLayout.listDatabaseFiles((dir, name) => name.Equals(IndexConfigStore.INDEX_DB_FILE_NAME));
     if (indexFiles != null)
     {
         foreach (File file in indexFiles)
         {
             Files.Add(_toNotAStoreTypeFile.apply(file));
         }
     }
     if (includeLogs)
     {
         File[] logFiles = this._logFiles.logFiles();
         foreach (File logFile in logFiles)
         {
             Files.Add(_logFileMapper.apply(logFile));
         }
     }
 }
Esempio n. 17
0
        public override void CheckConsistency(RECORD record, CheckerEngine <RECORD, REPORT> engine, RecordAccess records)
        {
            if (!Record.NO_NEXT_PROPERTY.@is(record.NextProp))
            {
                // Check the whole chain here instead of scattered during multiple checks.
                // This type of check obviously favors chains with good locality, performance-wise.
                IEnumerator <PropertyRecord> props = records.RawPropertyChain(record.NextProp);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                PropertyRecord firstProp = props.next();
                if (!Record.NO_PREVIOUS_PROPERTY.@is(firstProp.PrevProp))
                {
                    engine.Report().propertyNotFirstInChain(firstProp);
                }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableIntSet keys = new org.eclipse.collections.impl.set.mutable.primitive.IntHashSet();
                MutableIntSet keys = new IntHashSet();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet propertyRecordIds = new org.eclipse.collections.impl.set.mutable.primitive.LongHashSet(8);
                MutableLongSet propertyRecordIds = new LongHashSet(8);
                propertyRecordIds.add(firstProp.Id);
                using (MandatoryProperties.Check <RECORD, REPORT> mandatory = _mandatoryProperties.apply(record))
                {
                    CheckChainItem(firstProp, engine, keys, mandatory);

                    // Check the whole chain here. We also take the opportunity to check mandatory property constraints.
                    PropertyRecord prop = firstProp;
                    while (props.MoveNext())
                    {
                        PropertyRecord nextProp = props.Current;
                        if (!propertyRecordIds.add(nextProp.Id))
                        {
                            engine.Report().propertyChainContainsCircularReference(prop);
                            break;
                        }
                        CheckChainItem(nextProp, engine, keys, mandatory);
                        prop = nextProp;
                    }
                }
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Performs a switch to the master state. Starts communication endpoints, switches components to the master state
        /// and broadcasts the appropriate Master Is Available event. </summary>
        /// <param name="haCommunicationLife"> The LifeSupport instance to register communication endpoints. </param>
        /// <param name="me"> The URI that the communication endpoints should bind to </param>
        /// <returns> The URI at which the master communication was bound. </returns>
//JAVA TO C# CONVERTER NOTE: Members cannot have the same name as their enclosing type:
        public virtual URI SwitchToMasterConflict(LifeSupport haCommunicationLife, URI me)
        {
            _userLog.info("I am %s, moving to master", MyId(_config));

            // Do not wait for currently active transactions to complete before continuing switching.
            // - A master in a cluster is very important, without it the cluster cannot process any write requests
            // - Awaiting open transactions to complete assumes that this instance just now was a slave that is
            //   switching to master, which means the previous master where these active transactions were hosted
            //   is no longer available so these open transactions cannot continue and complete anyway,
            //   so what's the point waiting for them?
            // - Read transactions may still be able to complete, but the correct response to failures in those
            //   is to have them throw transient error exceptions hinting that they should be retried,
            //   at which point they may get redirected to another instance, or to this instance if it has completed
            //   the switch until then.

            _idGeneratorFactory.switchToMaster();
            NeoStoreDataSource dataSource = _dataSourceSupplier.get();

            dataSource.AfterModeSwitch();

            Locks locks = dataSource.DependencyResolver.resolveDependency(typeof(Locks));
            ConversationManager conversationManager = ConversationManagerFactory.apply(locks);
            Master master = MasterFactory.apply(conversationManager, haCommunicationLife);

            MasterServer masterServer = MasterServerFactory.apply(master, conversationManager);

            haCommunicationLife.Add(masterServer);
            _masterDelegateHandler.Delegate = master;

            haCommunicationLife.Start();

            URI masterHaURI = GetMasterUri(me, masterServer, _config);

            _clusterMemberAvailability.memberIsAvailable(MASTER, masterHaURI, dataSource.StoreId);
            _userLog.info("I am %s, successfully moved to master", MyId(_config));

            _slaveFactorySupplier.get().StoreId = dataSource.StoreId;

            return(masterHaURI);
        }
Esempio n. 19
0
        public override double?apply(double[] x)
        {
            ArgChecker.notNull(x, "x");
            ArgChecker.isTrue(x.Length >= 4, "Need at least four points to calculate kurtosis");
            double sum      = 0;
            double mean     = MEAN.apply(x);
            double variance = 0;

            foreach (double?d in x)
            {
                double diff   = d - mean;
                double diffSq = diff * diff;
                variance += diffSq;
                sum      += diffSq * diffSq;
            }
            int    n  = x.Length;
            double n1 = n - 1;
            double n2 = n1 - 1;

            variance /= n1;
            return(n * (n + 1.0) * sum / (n1 * n2 * (n - 3.0) * variance * variance) - 3 * n1 * n1 / (n2 * (n - 3.0)));
        }
Esempio n. 20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldComputeTheLastTxInfoCorrectly() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldComputeTheLastTxInfoCorrectly()
        {
            // given
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            File           prepare        = _directory.directory("prepare");

            MigrationTestUtils.prepareSampleLegacyDatabase(Version, _fs, databaseLayout.DatabaseDirectory(), prepare);
            // and a state of the migration saying that it has done the actual migration
            LogService         logService         = NullLogService.Instance;
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fs);
            LogTailScanner     tailScanner        = GetTailScanner(databaseLayout.DatabaseDirectory());
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache, tailScanner);

            string versionToMigrateFrom = upgradableDatabase.CheckUpgradable(databaseLayout).storeVersion();
            SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
            StoreMigrator  migrator        = new StoreMigrator(_fs, pageCache, _config, logService, _jobScheduler);
            DatabaseLayout migrationLayout = _directory.databaseLayout(StoreUpgrader.MIGRATION_DIRECTORY);

            // when
            migrator.Migrate(databaseLayout, migrationLayout, progressMonitor.StartSection("section"), versionToMigrateFrom, upgradableDatabase.CurrentVersion());

            // then
            assertTrue(TxIdComparator.apply(migrator.ReadLastTxInformation(migrationLayout)));
        }
Esempio n. 21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void replace()
        public virtual void Replace()
        {
            assertThat(Value.apply("hello").replace("l", "w"), equalTo(Value.apply("hewwo")));
            assertThat(Value.apply("hello").replace("ell", "ipp"), equalTo(Value.apply("hippo")));
            assertThat(Value.apply("hello").replace("a", "x"), equalTo(Value.apply("hello")));
            assertThat(Value.apply("hello").replace("e", ""), equalTo(Value.apply("hllo")));
            assertThat(Value.apply("").replace("", "⁻"), equalTo(Value.apply("⁻")));
        }
Esempio n. 22
0
 internal virtual I Create(IList <ModifierProtocolInstaller <O> > modifiers)
 {
     return(Constructor.apply(modifiers));
 }
Esempio n. 23
0
            protected internal override BatchTransactionApplierFacade Applier(TransactionApplicationMode mode, IndexActivator indexActivator)
            {
                BatchTransactionApplierFacade recordEngineApplier = base.Applier(mode, indexActivator);

                return(TransactionApplierTransformer.apply(recordEngineApplier));
            }
Esempio n. 24
0
        public override void Process(NodeRecord nodeRecord)
        {
            _reporter.forNode(nodeRecord, _nodeIndexCheck);
            Org.Neo4j.Consistency.checking.cache.CacheAccess_Client client = _cacheAccess.client();
            using (MandatoryProperties.Check <NodeRecord, ConsistencyReport_NodeConsistencyReport> mandatoryCheck = _mandatoryProperties.apply(nodeRecord))
            {
                IEnumerable <PropertyRecord> properties = client.PropertiesFromCache;

                // We do this null-check here because even if nodeIndexCheck should provide the properties for us,
                // or an empty list at least, it may fail in one way or another and exception be caught by
                // broad exception handler in reporter. The caught exception will produce an ERROR so it will not
                // go by unnoticed.
                if (properties != null)
                {
                    foreach (PropertyRecord property in properties)
                    {
                        _reporter.forProperty(property, _propertyCheck);
                        mandatoryCheck.Receive(ChainCheck.keys(property));
                    }
                }
            }
        }
Esempio n. 25
0
 public override int GetRecordSize(StoreHeader header)
 {
     return(_recordSize.apply(header));
 }
Esempio n. 26
0
 private DatabaseIdContext CreateIdContext(IdGeneratorFactory idGeneratorFactory, IdController idController)
 {
     return(new DatabaseIdContext(_factoryWrapper.apply(idGeneratorFactory), idController));
 }
Esempio n. 27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expectedExceptions = IllegalArgumentException.class) public void testLow()
        public virtual void testLow()
        {
            BETA.apply(-0.3);
        }
Esempio n. 28
0
 public override StructureBuilder <Input, Result> Add(string field, Input value)
 {
     _builder.add(field, _mapping.apply(value));
     return(this);
 }
 public override double?apply(double?x)
 {
     ArgChecker.notNull(x, "x");
     ArgChecker.notNegative(x, "x");
     return(_calc.apply(0.5 + 0.5 * x));
 }
Esempio n. 30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expectedExceptions = IllegalArgumentException.class) public void testNull()
        public virtual void testNull()
        {
            F.apply((double?)null);
        }