/** @tests java.util.Arrays#toString(short[]) */ public void test_toString$S() { assertEquals("null", Arrays.toString((short[]) null)); assertEquals("[]", Arrays.toString(new short[] {})); assertEquals("[0]", Arrays.toString(new short[] {0})); assertEquals("[-1, 0]", Arrays.toString(new short[] {-1, 0})); assertEquals("[-1, 0, 1]", Arrays.toString(new short[] {-1, 0, 1})); }
public void assertAll(Iterable<Diagnostic> asserted, DiagnosticPredicate predicates[]) { HashMap<DiagnosticPredicate, Boolean> consumed = new HashMap<DiagnosticPredicate, Boolean>(); for (DiagnosticPredicate p : predicates) consumed.put(p, Boolean.FALSE); for (Diagnostic d : asserted) { boolean found = false; for (Entry<DiagnosticPredicate, Boolean> e : consumed.entrySet()) if ((!e.getValue() || e.getKey().isGreedy()) && e.getKey().apply(d)) { consumed.put(e.getKey(), Boolean.TRUE); found = true; break; } if (!found) { if (predicates.length == 1) throw new ComparisonFailure( "Predicate does not match", predicates[0].toString(), diagnosticsToString(d)); throw new ComparisonFailure( "No predicate in expected matches", Arrays.toString(predicates), diagnosticsToString(d)); } } ArrayList<DiagnosticPredicate> unconsumed = new ArrayList<DiagnosticPredicate>(); for (Entry<DiagnosticPredicate, Boolean> e : consumed.entrySet()) if (!e.getValue() && e.getKey().isRequired()) unconsumed.add(e.getKey()); if (unconsumed.size() != 0) throw new ComparisonFailure( "Missing diagnostics for required predicates", Arrays.toString(unconsumed.toArray()), diagnosticsToString(asserted)); }
public static void setBestPreviewFPS(Camera.Parameters parameters, int minFPS, int maxFPS) { List<int[]> supportedPreviewFpsRanges = parameters.getSupportedPreviewFpsRange(); Log.i(TAG, "Supported FPS ranges: " + toString(supportedPreviewFpsRanges)); if (supportedPreviewFpsRanges != null && !supportedPreviewFpsRanges.isEmpty()) { int[] suitableFPSRange = null; for (int[] fpsRange : supportedPreviewFpsRanges) { int thisMin = fpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX]; int thisMax = fpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]; if (thisMin >= minFPS * 1000 && thisMax <= maxFPS * 1000) { suitableFPSRange = fpsRange; break; } } if (suitableFPSRange == null) { Log.i(TAG, "No suitable FPS range?"); } else { int[] currentFpsRange = new int[2]; parameters.getPreviewFpsRange(currentFpsRange); if (Arrays.equals(currentFpsRange, suitableFPSRange)) { Log.i(TAG, "FPS range already set to " + Arrays.toString(suitableFPSRange)); } else { Log.i(TAG, "Setting FPS range to " + Arrays.toString(suitableFPSRange)); parameters.setPreviewFpsRange( suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX], suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]); } } } }
private void assertProposedMethods( String finderName, String[] properties, String[] superProperties, String[] expectedMethodProposalNames) throws JavaModelException { String superName = null; if (superProperties != null) { superName = "SearchSuper"; createDomainClass( "SearchSuper", createDomainTextWithSuper(null, null, true, superProperties)); } String contents = createDomainTextWithSuper(finderName, superName, false, properties); // ensure this is executed in a static context GroovyCompilationUnit unit = createDomainClass("Search", contents); DynamicFinderValidator validator = new FinderValidatorFactory() .createValidator(GrailsWorkspaceCore.get().create(project).getDomainClass(unit)); List<AnnotatedNode> proposed = validator.findProposals(finderName); String[] actualMethodProposalNames = getProposalNames(proposed); Arrays.sort(expectedMethodProposalNames); Arrays.sort(actualMethodProposalNames); assertTrue( "Actual and expected proposals not the same.\nExpected: " + Arrays.toString(expectedMethodProposalNames) + "\nActual: " + Arrays.toString(actualMethodProposalNames), testSameElements(expectedMethodProposalNames, actualMethodProposalNames)); }
@Override public String toString() { return "foodArea=" + foodArea + "\n" + "woodArea=" + woodArea + "\n" + "copperArea=" + copperArea + "\n" + "stoneArea=" + stoneArea + "\n" + "goldArea=" + goldArea + "\n" + "hutArea=" + hutArea + "\n" + "farmArea=" + farmArea + "\n" + "factoryArea=" + factoryArea + "\n" + "buildingAreas=" + Arrays.toString(buildingAreas) + "\n" + "civilisationAreas=" + Arrays.toString(civilisationAreas); }
@Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append('['); builder.append(standard); builder.append(','); if (hasPayee()) { builder.append(payeeName); if (payeeVerifiedBy != null) builder.append("/").append(payeeVerifiedBy); builder.append(','); } builder.append(hasOutputs() ? Arrays.toString(outputs) : "null"); builder.append(','); builder.append(paymentUrl); if (payeeData != null) { builder.append(','); builder.append(Arrays.toString(payeeData)); } if (paymentRequestUrl != null) { builder.append(",paymentRequestUrl="); builder.append(paymentRequestUrl); } builder.append(']'); return builder.toString(); }
private final void typeCheck(String externs, String js, DiagnosticType... warningKinds) { parseAndTypeCheck(externs, js); JSError[] warnings = compiler.getWarnings(); JSError[] errors = compiler.getErrors(); String errorMessage = "Expected warning of type:\n" + "================================================================\n" + Arrays.toString(warningKinds) + "================================================================\n" + "but found:\n" + "----------------------------------------------------------------\n" + Arrays.toString(errors) + Arrays.toString(warnings) + "\n" + "----------------------------------------------------------------\n"; assertEquals( errorMessage + "Warning count", warningKinds.length, warnings.length + errors.length); for (JSError warning : warnings) { assertTrue( "Wrong warning type\n" + errorMessage, Arrays.asList(warningKinds).contains(warning.getType())); } for (JSError error : errors) { assertTrue( "Wrong warning type\n" + errorMessage, Arrays.asList(warningKinds).contains(error.getType())); } }
@Around("loggingPointcut()") public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { if (log.isDebugEnabled()) { log.debug( "Enter: {}.{}() with argument[s] = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs())); } try { Object result = joinPoint.proceed(); if (log.isDebugEnabled()) { log.debug( "Exit: {}.{}() with result = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), result); } return result; } catch (IllegalArgumentException e) { log.error( "Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()), joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName()); throw e; } }
public static void testAllEqual() { Address[] mbrs = Util.createRandomAddresses(5); View[] views = { View.create(mbrs[0], 1, mbrs), View.create(mbrs[0], 1, mbrs), View.create(mbrs[0], 1, mbrs) }; boolean same = Util.allEqual(Arrays.asList(views)); System.out.println("views=" + Arrays.toString(views) + ", same = " + same); assert same; views = new View[] { View.create(mbrs[0], 1, mbrs), View.create(mbrs[0], 2, mbrs), View.create(mbrs[0], 1, mbrs) }; same = Util.allEqual(Arrays.asList(views)); System.out.println("views=" + Arrays.toString(views) + ", same = " + same); assert !same; views = new View[] { View.create(mbrs[1], 1, mbrs), View.create(mbrs[0], 1, mbrs), View.create(mbrs[0], 1, mbrs) }; same = Util.allEqual(Arrays.asList(views)); System.out.println("views=" + Arrays.toString(views) + ", same = " + same); assert !same; }
public void testdetermineFnameAndExtension() { String sep = System.getProperty("file.separator"); Map<String, String[]> fnamesAndGoldStandard = new HashMap<String, String[]>(); fnamesAndGoldStandard.put("a" + sep + "b", new String[] {"a" + sep + "b", ""}); fnamesAndGoldStandard.put("a" + sep + "b.", new String[] {"a" + sep + "b", ""}); fnamesAndGoldStandard.put("a" + sep + "b.c", new String[] {"a" + sep + "b", "c"}); fnamesAndGoldStandard.put("a.c" + sep + "b", new String[] {"a.c" + sep + "b", ""}); fnamesAndGoldStandard.put("a.c" + sep + "b.c", new String[] {"a.c" + sep + "b", "c"}); fnamesAndGoldStandard.put("a", new String[] {"a", ""}); fnamesAndGoldStandard.put("a.c", new String[] {"a", "c"}); fnamesAndGoldStandard.put("a.", new String[] {"a", ""}); fnamesAndGoldStandard.put("a." + sep + "b", new String[] {"a." + sep + "b", ""}); fnamesAndGoldStandard.put("a." + sep + "b.", new String[] {"a." + sep + "b", ""}); fnamesAndGoldStandard.put("a." + sep + "b.c", new String[] {"a." + sep + "b", "c"}); for (Entry<String, String[]> e : fnamesAndGoldStandard.entrySet()) { String[] fnExt = Util.determineFnameAndExtension(e.getKey()); System.out.println( e.getKey() + " " + Arrays.toString(e.getValue()) + " " + Arrays.toString(fnExt)); assertEquals(fnExt[0], e.getValue()[0]); assertEquals(fnExt[1], e.getValue()[1]); } }
@Test public void testAdamUpdater() { INDArray m, v; double lr = 0.01; int iteration = 0; double beta1 = 0.8; double beta2 = 0.888; NeuralNetConfiguration conf = new NeuralNetConfiguration.Builder() .learningRate(lr) .iterations(iteration) .adamMeanDecay(beta1) .adamVarDecay(beta2) .layer( new DenseLayer.Builder() .nIn(nIn) .nOut(nOut) .updater(org.deeplearning4j.nn.conf.Updater.ADAM) .build()) .build(); int numParams = LayerFactories.getFactory(conf).initializer().numParams(conf, true); INDArray params = Nd4j.create(1, numParams); Layer layer = LayerFactories.getFactory(conf).create(conf, null, 0, params, true); Updater updater = UpdaterCreator.getUpdater(layer); int updaterStateSize = updater.stateSizeForLayer(layer); INDArray updaterState = Nd4j.create(1, updaterStateSize); updater.setStateViewArray(layer, updaterState, true); updater.update(layer, gradient, iteration, 1); double beta1t = FastMath.pow(beta1, iteration); double beta2t = FastMath.pow(beta2, iteration); double alphat = lr * FastMath.sqrt(1 - beta2t) / (1 - beta1t); if (Double.isNaN(alphat) || alphat == 0.0) alphat = epsilon; Gradient gradientDup = new DefaultGradient(); gradientDup.setGradientFor(DefaultParamInitializer.WEIGHT_KEY, weightGradient); gradientDup.setGradientFor(DefaultParamInitializer.BIAS_KEY, biasGradient); for (Map.Entry<String, INDArray> entry : gradientDup.gradientForVariable().entrySet()) { val = entry.getValue(); m = Nd4j.zeros(val.shape()); v = Nd4j.zeros(val.shape()); m.muli(beta1).addi(val.mul(1.0 - beta1)); v.muli(beta2).addi(val.mul(val).mul(1.0 - beta2)); gradExpected = m.mul(alphat).divi(Transforms.sqrt(v).addi(epsilon)); if (!gradExpected.equals(gradient.getGradientFor(entry.getKey()))) { System.out.println(Arrays.toString(gradExpected.dup().data().asFloat())); System.out.println( Arrays.toString(gradient.getGradientFor(entry.getKey()).dup().data().asFloat())); } assertEquals(gradExpected, gradient.getGradientFor(entry.getKey())); } assertEquals(beta1, layer.conf().getLayer().getAdamMeanDecay(), 1e-4); assertEquals(beta2, layer.conf().getLayer().getAdamVarDecay(), 1e-4); }
protected void onPostExecute(BusStop myStop) { try { stopText = (TextView) findViewById(R.id.show_title); stopText.append(myStop.getRouteNumber()); inboundText = (TextView) findViewById(R.id.inbound); inboundText.append(Double.toString(myStop.getLatitude())); outboundText = (TextView) findViewById(R.id.outbound); outboundText.append(Double.toString(myStop.getLongitude())); test = (TextView) findViewById(R.id.page_source); int[] inboundMinutes = timesToMinutes(myStop.getInboundTimes()); int[] outboundMinutes = timesToMinutes(myStop.getOutboundTimes()); test.setText(Arrays.toString(inboundMinutes)); test.append("\n" + Arrays.toString(outboundMinutes)); test.append("\n" + minutesToTime(nextTime(outboundMinutes))); try { FileOutputStream fileWriter; String fileName = myStop.getRouteNumber() + ".txt"; fileWriter = openFileOutput(fileName, MODE_APPEND); fileWriter.write((fileName.substring(0, 5) + "\n").getBytes()); fileWriter.write((Double.toString(myStop.getLatitude()) + "\n").getBytes()); fileWriter.write((Double.toString(myStop.getLongitude()) + "\n").getBytes()); fileWriter.write((Arrays.toString(inboundMinutes) + "\n").getBytes()); fileWriter.write((Arrays.toString(outboundMinutes) + "\n").getBytes()); } catch (IOException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } }
public static void main(String[] args) throws UnsupportedEncodingException { byte[] bytes = {70, 71, 72}; String str = new String(bytes, "UTF-8"); System.out.println(str); char[] chars = str.toCharArray(); System.out.println(chars); // System.out.println(); - маЇ дек≥лька Overloading метод≥в, тому по р≥зному виводить результат System.out.println(chars[0]); System.out.println(chars[1] + 0); System.out.println((int) chars[2]); // ќдн byte[] може збер≥гати збер≥гати р≥зну к≥льк≥сть елемент≥в char[] bytes = new byte[] {100, -101, 70}; System.out.println(Arrays.toString(new String(bytes, "UTF-8").toCharArray())); System.out.println(Arrays.toString(new String(bytes, "cp1251").toCharArray())); System.out.println(Arrays.toString(new String(bytes, "UTF-16").toCharArray())); // ус≥ три записи р≥вн≥ String str0 = "\u0040\u0040"; // unicod System.out.println(str0); String str1 = new String(new char[] {64, 64}); // Dec (10) System.out.println(str1); String str2 = new String(new char[] {0x40, 0x40}); // Hex (16) System.out.println(str2); }
// This function return Daat and Taat postings of the queries passed in the List public static void writePostingList(List<String> list, String outputfileName) { try { Map<String, List<Integer>> postingMap = new TreeMap<String, List<Integer>>(); FileWriter writer = new FileWriter(new File(outputfileName), true); // second arguemtn gives output filename for (int i = 0; i < list.size(); i++) { // System.out.println("printing list items"+list.get(i)); String key = list.get(i); writer.write("FUNCTION: getPostings " + key + "\n"); if (indexMap1DaaT.containsKey(key)) { String tempstringDaat = Arrays.toString(indexMap1DaaT.get(key).toArray()); tempstringDaat = tempstringDaat.substring(1, tempstringDaat.length() - 1); String tempstringTaat = Arrays.toString(indexMap2TaaT.get(key).toArray()); tempstringTaat = tempstringTaat.substring(1, tempstringTaat.length() - 1); writer.write("Ordered by Doc IDs: " + tempstringDaat + "\n"); writer.write("Ordered by TF: " + tempstringTaat + "\n"); } else writer.write("term not found\n"); } writer.close(); } catch (Exception e) { e.printStackTrace(); } }
@Override public void onRequestPermissionsResult( int requestCode, String[] permissions, int[] grantResults) { Log.d( "RALMN", String.valueOf(requestCode) + " - " + Arrays.toString(permissions) + " " + Arrays.toString(grantResults)); if (Arrays.asList(permissions).contains(Manifest.permission.READ_CALENDAR) && checkSelfPermission(Manifest.permission.READ_CALENDAR) == PackageManager.PERMISSION_GRANTED) { Log.v("WAKEMEUP", "Perms Read caleander allowed"); SharedPreferences sharedPreferences = getSharedPreferences("fr.ralmn.wakemeup", MODE_PRIVATE); if (!sharedPreferences.contains("calendars")) { HashSet<String> calendarsId = new HashSet<>(); List<AndroidCalendar> androidCalendars = CalendarHelper.getCalendars(this); for (AndroidCalendar androidCalendar : androidCalendars) { calendarsId.add(androidCalendar.getId() + ""); } sharedPreferences.edit().putStringSet("calendars", calendarsId).apply(); } ListView alarmList = (ListView) findViewById(R.id.alarmsListView); List<Alarm> alarms = CalendarHelper.calculateWeekAlarms(this); // Alarm.getAlarms(this); Collections.sort(alarms); CalendarHelper.calculateNextAlarm(this); alarmList.setAdapter(new AlarmArrayAdapter(this, R.layout.alarm_list_item, alarms)); } }
public PossibilityDegreeMismathcException(FuzzySymbolicDomain v, double[] vals) { super( "Symbols " + Arrays.toString(v.getSymbols()) + " do not match possibility degrees " + Arrays.toString(vals)); }
@Override protected void specificDemo() { print(String.format("Complexity: %s\n", problem.getBigO())); print("Inputs:"); printf("min:%d max:%d\n", input.get("min"), input.get("max")); print("array: " + Arrays.toString((int[]) input.get("array"))); stopwatch.start(); print("Output:" + problem.solve(input)); print(repeatString("=", 50)); stopwatch.stop(); print(stopwatch.readAsString()); stopwatch.reset(); // 2nd demo input.put("min", 0); input.put("max", 10); input.put("array", new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); print("Inputs: (complete array demo)"); printf("min:%d max:%d\n", input.get("min"), input.get("max")); print("array: " + Arrays.toString((int[]) input.get("array"))); stopwatch.start(); print("Output:" + problem.solve(input)); print(stopwatch.readAsString()); stopwatch.stop(); print(repeatString("=", 50)); stopwatch.reset(); }
public static String[] getClassRoots() { String testRoots = System.getProperty("test.roots"); if (testRoots != null) { System.out.println( "Collecting tests from roots specified by test.roots property: " + testRoots); return testRoots.split(";"); } final String[] roots = ExternalClasspathClassLoader.getRoots(); if (roots != null) { System.out.println( "Collecting tests from roots specified by classpath.file property: " + Arrays.toString(roots)); return roots; } else { final ClassLoader loader = TestAll.class.getClassLoader(); if (loader instanceof URLClassLoader) { final URL[] urls = ((URLClassLoader) loader).getURLs(); final String[] classLoaderRoots = new String[urls.length]; for (int i = 0; i < urls.length; i++) { classLoaderRoots[i] = VfsUtil.urlToPath(VfsUtil.convertFromUrl(urls[i])); } System.out.println( "Collecting tests from classloader: " + Arrays.toString(classLoaderRoots)); return classLoaderRoots; } return System.getProperty("java.class.path").split(File.pathSeparator); } }
public static void main(String[] args) { // Sorting sr = new Sorting(); // int[] unSortedArray = {1, 4, 10, 0, 2, 9}; // System.out.println(Arrays.toString(sr.swap(unSortedArray, 0, 4))); // sr.selectionSort(unSortedArray); // int[] sortedArray = sr.bubbleSort(unSortedArray); // System.out.println(Arrays.toString(sortedArray)); // String result = (sr.binarySearch(sortedArray, 0, // sortedArray.length - 1, 11) != -1) ? "Match found" : "No Match"; // System.out.println(result + " at " + sr.binarySearch(sortedArray, 0, // sortedArray.length - 1, 11) + "th position"); // System.out.println(sr.binarySearch(sortedArray, 0, // sortedArray.length - 1, 8)); Scanner scan = new Scanner(System.in); int len = scan.nextInt(); Integer[] arrIn = new Integer[len]; for (int i = 0; i < len; i++) { arrIn[i] = scan.nextInt(); } System.out.println("Input: First Line: " + len + "--- Second Line: " + Arrays.toString(arrIn)); Arrays.sort(arrIn, Collections.reverseOrder()); System.out.println(Arrays.toString(arrIn)); // insertionSort1(len, arrIn); }
/** * Debugging printout * * @return String with useful info */ public String toStringAll() { StringBuilder sb = new StringBuilder(); sb.append(toString()); for (int i = 0; i < units.length - 1; ++i) sb.append("\nweights[") .append(i) .append("][]=") .append(Arrays.toString(get_weights(i).raw())); for (int i = 0; i < units.length - 1; ++i) { sb.append("\nbiases[").append(i).append("][]=").append(Arrays.toString(get_biases(i).raw())); } if (has_momenta()) { for (int i = 0; i < units.length - 1; ++i) sb.append("\nweights_momenta[") .append(i) .append("][]=") .append(Arrays.toString(get_weights_momenta(i).raw())); } if (biases_momenta != null) { for (int i = 0; i < units.length - 1; ++i) { sb.append("\nbiases_momenta[") .append(i) .append("][]=") .append(Arrays.toString(biases_momenta[i].raw())); } } sb.append("\nunits[]=").append(Arrays.toString(units)); sb.append("\nprocessed global: ").append(get_processed_global()); sb.append("\nprocessed local: ").append(get_processed_local()); sb.append("\nprocessed total: ").append(get_processed_total()); sb.append("\n"); return sb.toString(); }
/** * Requests "dangerous" permissions for the application at runtime. This is a helper method * alternative to cordovaInterface.requestPermissions() that does not require the project to be * built with cordova-android 5.0.0+ * * @param plugin The plugin the permissions are being requested for * @param requestCode A requestCode to be passed to the plugin's onRequestPermissionResult() along * with the result of the permissions request * @param permissions The permissions to be requested */ public static void requestPermissions( CordovaPlugin plugin, int requestCode, String[] permissions) { try { Method requestPermission = CordovaInterface.class.getDeclaredMethod( "requestPermissions", CordovaPlugin.class, int.class, String[].class); // If there is no exception, then this is cordova-android 5.0.0+ requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions); } catch (NoSuchMethodException noSuchMethodException) { // cordova-android version is less than 5.0.0, so permission is implicitly granted LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions)); // Notify the plugin that all were granted by using more reflection deliverPermissionResult(plugin, requestCode, permissions); } catch (IllegalAccessException illegalAccessException) { // Should never be caught; this is a public method LOG.e( LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException); } catch (InvocationTargetException invocationTargetException) { // This method does not throw any exceptions, so this should never be caught LOG.e( LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException); } }
public void testGetLocalBlessingNames() throws Exception { VContext context = V.init(); VPrincipal p1 = VSecurity.newPrincipal(); VPrincipal p2 = VSecurity.newPrincipal(); Blessings alice = p1.blessSelf("alice"); VSecurity.addToRoots(p2, alice); Blessings aliceWorkFriend = p1.bless(p2.publicKey(), alice, "work:friend", VSecurity.newUnconstrainedUseCaveat()); Call call = VSecurity.newCall( new CallParams().withLocalBlessings(aliceWorkFriend).withLocalPrincipal(p2)); String[] blessings = VSecurity.getLocalBlessingNames(context, call); if (!Arrays.equals(new String[] {"alice:work:friend"}, blessings)) { fail( String.format( "Expected blessings [\"alice:work:friend\"], got %s", Arrays.toString(blessings))); } blessings = VSecurity.getBlessingNames(p2, aliceWorkFriend); if (!Arrays.equals(new String[] {"alice:work:friend"}, blessings)) { fail( String.format( "Expected blessings [\"alice:work:friend\"], got %s", Arrays.toString(blessings))); } blessings = VSecurity.getBlessingNames(p1, aliceWorkFriend); if (!Arrays.equals(new String[] {}, blessings)) { fail(String.format("Expected blessings [], got %s", Arrays.toString(blessings))); } }
@Override public VolatileFloatArray loadArray( final int timepoint, final int setup, final int level, final int[] dimensions, final long[] min) throws InterruptedException { float[] data = null; final MDFloatArray slice = reader.readMDArrayBlockWithOffset( dataset, new int[] {dimensions[2], dimensions[1], dimensions[0]}, new long[] {min[2], min[1], min[0]}); data = slice.getAsFlatArray(); if (data == null) { System.out.println( "H5 float array loader failed loading min = " + Arrays.toString(min) + ", dimensions = " + Arrays.toString(dimensions)); data = new float[dimensions[0] * dimensions[1] * dimensions[2]]; } return new VolatileFloatArray(data, true); }
public static void main(String[] args) { int[] arr; arr = new int[] {0, 1, 2}; System.out.print(Arrays.toString(arr) + "->"); fdg.invert(arr); System.out.println(Arrays.toString(arr)); }
public static void assertChain(TestdataChainedObject... chainedObjects) { TestdataChainedObject chainedObject = chainedObjects[0]; for (int i = 1; i < chainedObjects.length; i++) { TestdataChainedEntity chainedEntity = (TestdataChainedEntity) chainedObjects[i]; if (!Objects.equals(chainedObject, chainedEntity.getChainedObject())) { fail( "Chain assertion failed for chainedEntity (" + chainedEntity + ").\n" + "Expected: " + chainedObject + "\n" + "Actual: " + chainedEntity.getChainedObject() + "\n" + "Expected chain: " + Arrays.toString(chainedObjects) + "\n" + "Actual chain: " + Arrays.toString(ArrayUtils.subarray(chainedObjects, 0, i)) + " ... [" + chainedEntity.getChainedObject() + ", " + chainedEntity + "] ..."); } chainedObject = chainedEntity; } }
/** * @return The calculated evalution function value (chi2) for the given parameter array. NOTE: * Does not change the value of chi2. */ protected double calculateChi2(double[] a) { double result = 0; for (int i = 0; i < yDataPoints.length; i++) { double dy = yDataPoints[i] - function.getY(xDataPoints[i], a); // check if NaN occurred if (Double.isNaN(dy)) { System.err.println( "Chi2 calculation produced a NaN value at point " + i + ":\n" + " x = " + Arrays.toString(xDataPoints[i]) + "\n" + " y = " + yDataPoints[i] + "\n" + " parameters: " + Arrays.toString(a) + "\n" + " iteration count = " + iterationCount); return Double.NaN; } result += weights[i] * dy * dy; } return result; }
// check if they are permutations public boolean compare(String a, String b) { char[] c1 = a.toCharArray(); char[] c2 = b.toCharArray(); Arrays.sort(c1); Arrays.sort(c2); return (Arrays.toString(c1).equals(Arrays.toString(c2))); }
@Test public void canCreateHTMLHybridApplication() { // Project is created within setup method assertTrue(new ProjectExplorer().containsProject(CORDOVA_PROJECT_NAME)); // Check there is no error/warning on Hybrid Mobile Project new ProjectExplorer().selectProjects(CORDOVA_PROJECT_NAME); ProblemsView pview = new ProblemsView(); pview.open(); List<Problem> errors = pview.getProblems( ProblemType.ERROR, new ProblemsPathMatcher(new RegexMatcher("(/" + CORDOVA_PROJECT_NAME + "/)(.*)"))); List<Problem> warnings = pview.getProblems( ProblemType.WARNING, new ProblemsPathMatcher(new RegexMatcher("(/" + CORDOVA_PROJECT_NAME + "/)(.*)"))); assertTrue( "There were these errors for " + CORDOVA_PROJECT_NAME + " project " + Arrays.toString(errors.toArray()), errors == null || errors.size() == 0); assertTrue( "There were these warnings for " + CORDOVA_PROJECT_NAME + " project " + Arrays.toString(warnings.toArray()), warnings == null || warnings.size() == 0); }
@Override public ResourceSchema getSchema(String location, Job job) throws IOException { if (!partitionKeysSet) { Set<String> keys = getPartitionColumns(location, job); if (!(keys == null || keys.size() == 0)) { // re-edit the pigSchema to contain the new partition keys. ResourceFieldSchema[] fields = pigSchema.getFields(); LOG.debug("Schema: " + Arrays.toString(fields)); ResourceFieldSchema[] newFields = Arrays.copyOf(fields, fields.length + keys.size()); int index = fields.length; for (String key : keys) { newFields[index++] = new ResourceFieldSchema(new FieldSchema(key, DataType.CHARARRAY)); } pigSchema.setFields(newFields); LOG.debug("Added partition fields: " + keys + " to loader schema"); LOG.debug("Schema is: " + Arrays.toString(newFields)); } partitionKeysSet = true; } return pigSchema; }
/** @tests java.util.Arrays#toString(float[]) */ public void test_toString$F() { assertEquals("null", Arrays.toString((float[]) null)); assertEquals("[]", Arrays.toString(new float[] {})); assertEquals("[0.0]", Arrays.toString(new float[] {0.0F})); assertEquals("[-1.0, 0.0]", Arrays.toString(new float[] {-1.0F, 0.0F})); assertEquals("[-1.0, 0.0, 1.0]", Arrays.toString(new float[] {-1.0F, 0.0F, 1.0F})); }