当前位置: 首页>>代码示例>>Java>>正文


Java AxesMetadata类代码示例

本文整理汇总了Java中org.eclipse.january.metadata.AxesMetadata的典型用法代码示例。如果您正苦于以下问题:Java AxesMetadata类的具体用法?Java AxesMetadata怎么用?Java AxesMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AxesMetadata类属于org.eclipse.january.metadata包,在下文中一共展示了AxesMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAxesMetadataReshape

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
@Test
public void testAxesMetadataReshape() throws MetadataException {
	final int[] shape = new int[] { 1, 2, 3, 1 };
	final int[] reshape = new int[] { 1, 1, 2, 3, 1 };

	int r = shape.length;
	int[] nShape = new int[r];
	AxesMetadata amd = MetadataFactory.createMetadata(AxesMetadata.class, r);
	for (int i = 0; i < r; i++) {
		Arrays.fill(nShape, 1);
		nShape[i] = shape[i];
		DoubleDataset array = Random.randn(nShape);
		amd.setAxis(i, array);
	}
	ILazyDataset dataset = Random.lazyRand(Dataset.INT32, "Main", shape);
	dataset.addMetadata(amd);
	dataset.setShape(reshape);
}
 
开发者ID:eclipse,项目名称:january,代码行数:19,代码来源:AxesMetadataTest.java

示例2: testAxesMetadataReshapeEmpty

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
@Test
public void testAxesMetadataReshapeEmpty() throws Exception {
	final int[] shape = new int[] { 1, 2, 3, 1 };

	int r = shape.length;

	ILazyDataset dataset = Random.lazyRand(Dataset.INT32, "Main", shape);

	AxesMetadata amd = MetadataFactory.createMetadata(AxesMetadata.class, r);
	dataset.addMetadata(amd);

	ILazyDataset v = dataset.getSliceView();
	v.squeezeEnds();
	assertEquals(2, v.getMetadata(AxesMetadata.class).get(0).getAxes().length);

	IDataset d = v.getSlice(new Slice(1), null);
	assertEquals(2, d.getMetadata(AxesMetadata.class).get(0).getAxes().length);

	final int[] reshape = new int[] { 1, 1, 2, 3, 1 };
	v.setShape(reshape);
	assertEquals(5, v.getMetadata(AxesMetadata.class).get(0).getAxes().length);

	d = v.getSlice((Slice) null, null, new Slice(1));
	assertEquals(5, d.getMetadata(AxesMetadata.class).get(0).getAxes().length);
}
 
开发者ID:eclipse,项目名称:january,代码行数:26,代码来源:AxesMetadataTest.java

示例3: testAxesMetadataTranspose

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
@Test
public void testAxesMetadataTranspose() throws Exception {
	final int[] shape = new int[] { 1, 2, 3, 4 };
	int r = shape.length;
	int[] nShape = new int[r];
	AxesMetadata amd = MetadataFactory.createMetadata(AxesMetadata.class, r);
	for (int i = 0; i < r; i++) {
		Arrays.fill(nShape, 1);
		nShape[i] = shape[i];
		DoubleDataset array = Random.randn(nShape);
		amd.setAxis(i, array);
	}

	Dataset dataset = Random.rand(shape);
	dataset.addMetadata(amd);

	int[] map = new int[] {3, 1, 2, 0};
	Dataset t = dataset.getTransposedView(map);
	assertArrayEquals(new int[]{4, 2, 3, 1}, t.getShape());
	amd = t.getMetadata(AxesMetadata.class).get(0);

	for (int i = 0; i < r; i++) {
		ILazyDataset a = amd.getAxis(i)[0];
		assertEquals(shape[map[i]], a.getSize());
	}
}
 
开发者ID:eclipse,项目名称:january,代码行数:27,代码来源:AxesMetadataTest.java

示例4: testSliceFromView

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
@Test
public void testSliceFromView() throws DatasetException {
	final int[] shape = new int[] { 3, 10, 11};
	final int[] ashape = new int[] {3};
	
	ILazyDataset dataset = Random.lazyRand(Dataset.INT32, "Main", shape);
	ILazyDataset ax = Random.lazyRand(Dataset.INT32, "Axis", ashape);
	
	AxesMetadata amd = MetadataFactory.createMetadata(AxesMetadata.class, shape.length);
    amd.setAxis(0, ax);
    dataset.setMetadata(amd); 
    
    ILazyDataset view = dataset.getSliceView(new Slice(1,2),null,null);
    IDataset slice = view.getSlice();
    assertTrue(slice != null);
}
 
开发者ID:eclipse,项目名称:january,代码行数:17,代码来源:AxesMetadataTest.java

示例5: testNonIndexedData

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
public void testNonIndexedData()
{
  LocationDocumentBuilder builder =
      new LocationDocumentBuilder(DOC_NAME, null, null);
  final IGeoCalculator calc = builder.getCalculator();
  for (int i = 0; i < 10; i++)
  {
    Point2D newP = calc.createPoint(i, i * 2);
    builder.add(newP);
  }

  LocationDocument res = builder.toDocument();
  assertNotNull("document produced", res);
  assertEquals("correct name", DOC_NAME, res.getName());
  assertEquals("has points", 10, res.getDataset().getSize());
  assertNull("doesn't have indices", res.getDataset().getFirstMetadata(
      AxesMetadata.class));
  
  String listing = res.toListing();
  assertNotNull(listing);
}
 
开发者ID:debrief,项目名称:limpet,代码行数:22,代码来源:TestLocations.java

示例6: testIndexedData

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
public void testIndexedData()
{
  LocationDocumentBuilder builder =
      new LocationDocumentBuilder(DOC_NAME, null, SampleData.MILLIS);
  final IGeoCalculator calc = builder.getCalculator();
  for (int i = 0; i < 10; i++)
  {
    Point2D newP = calc.createPoint(i, i * 2);
    builder.add((long) (i * 100000), newP);
  }

  LocationDocument res = builder.toDocument();
  assertNotNull("document produced", res);
  assertEquals("correct name", DOC_NAME, res.getName());
  assertEquals("has points", 10, res.getDataset().getSize());
  assertNotNull("has indices", res.getDataset().getFirstMetadata(
      AxesMetadata.class));
  
  String listing = res.toListing();
  assertNotNull(listing);
}
 
开发者ID:debrief,项目名称:limpet,代码行数:22,代码来源:TestLocations.java

示例7: getOperation

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
@Override
protected IOperationPerformer getOperation()
{
  return new InterpolatedMaths.IOperationPerformer()
  {
    @Override
    public Dataset
        perform(final Dataset a, final Dataset b, final Dataset o)
    {
      // ok, we're going to use dataset a as the new index units,
      // so we've just got to set them in a copy of b
      final Dataset output = b.clone();

      // clear any existing metadata
      output.clearMetadata(AxesMetadata.class);

      // now store the new metadata
      final AxesMetadata am = new AxesMetadataImpl();
      am.initialize(1);
      am.setAxis(0, a);
      output.addMetadata(am);

      return output;
    }
  };
}
 
开发者ID:debrief,项目名称:limpet,代码行数:27,代码来源:CreateNewIndexedDatafileOperation.java

示例8: findIndexDataset

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
protected Dataset findIndexDataset()
{
  Dataset ds = null;
  for (final IStoreItem inp : getInputs())
  {
    final Document<?> doc = (Document<?>) inp;
    if (doc.size() > 1 && doc.isIndexed())
    {
      final IDataset dataset = doc.getDataset();
      final AxesMetadata axes = dataset.getFirstMetadata(AxesMetadata.class);
      if (axes != null)
      {
        final DoubleDataset ds1 = (DoubleDataset) axes.getAxis(0)[0];
        ds = ds1;
        break;
      }
    }
  }

  return ds;
}
 
开发者ID:debrief,项目名称:limpet,代码行数:22,代码来源:CoreQuantityCommand.java

示例9: performCalc

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
/**
     * wrap the actual operation. We're doing this since we need to separate it from the core
     * "execute" operation in order to support dynamic updates
     * 
     * @param nd
     * 
     * @param unit
     *          the units to use
     * @param outputs
     *          the list of output series
     */
    protected IDataset performCalc(final NumberDocument nd)
    {
      final DoubleDataset ds = (DoubleDataset) nd.getDataset();

      // ok, re-calculate this
      Dataset res = calculate(ds);

      // store the axes
      final AxesMetadata axis1 = ds.getFirstMetadata(AxesMetadata.class);

      // if there are indices, store them
      if (axis1 != null)
      {
        res.addMetadata(axis1.clone());
//        final AxesMetadata am = new AxesMetadataImpl();
//        // keep track of the indices to use in the output
//        final DoubleDataset outputIndices = (DoubleDataset) axis1.getAxes()[0];
//        am.initialize(1);
//        am.setAxis(0, outputIndices);
//        res.addMetadata(am);
      }

      // done
      return res;
    }
 
开发者ID:debrief,项目名称:limpet,代码行数:37,代码来源:UnaryQuantityOperation.java

示例10: isIndexed

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
@Override
@UIProperty(name = "Indexed", category = UIProperty.CATEGORY_LABEL)
public boolean isIndexed()
{
  final boolean res;
  if (dataset != null)
  {
    // is there an axis?
    final AxesMetadata am = dataset.getFirstMetadata(AxesMetadata.class);

    // is it a time axis?
    res = am != null;
  }
  else
  {
    res = false;
  }

  return res;
}
 
开发者ID:debrief,项目名称:limpet,代码行数:21,代码来源:Document.java

示例11: getIndexValues

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
@Override
public DoubleDataset getIndexValues()
{
  DoubleDataset res;

  if (isIndexed())
  {
    final AxesMetadata am = dataset.getFirstMetadata(AxesMetadata.class);

    DoubleDataset dd = (DoubleDataset) am.getAxes()[0];
    res = dd;
  }
  else
  {
    throw new IllegalArgumentException("Dataset isn't indexed");
  }

  return res;
}
 
开发者ID:debrief,项目名称:limpet,代码行数:20,代码来源:Document.java

示例12: toListing

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
@Override
public String toListing()
{
  final StringBuffer res = new StringBuffer();

  final DoubleDataset dataset = (DoubleDataset) this.getDataset();
  final AxesMetadata axesMetadata =
      dataset.getFirstMetadata(AxesMetadata.class);

  final int[] dims = dataset.getShape();
  if (dims.length == 1)
  {
    toListing1D(res, dataset, axesMetadata);
  }
  else if (dims.length == 2)
  {
    toListing2D(res, dataset, axesMetadata, dims);
  }

  return res.toString();
}
 
开发者ID:debrief,项目名称:limpet,代码行数:22,代码来源:NumberDocument.java

示例13: updateShape

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
public void updateShape() {
	try {
		lazy.refreshShape();
		int[] current = lazy.getShape();
		for (IDynamicDataset k : keys) k.refreshShape();
		int[] s = DynamicMetadataUtils.refreshDynamicAxesMetadata(lazy.getMetadata(AxesMetadata.class), lazy.getShape());
		logger.info("Dynamic iterator setting max shape " + Arrays.toString(s) + " for lazy shape " + Arrays.toString(current));
		for (int i = 0; i < axes.length;i++) {
			s[axes[i]] = current[axes[i]];
		}
		lazy.resize(s);
		iterator.updateShape(lazy.getShape(), mergeKeys(keys));
	} catch (Exception e) {
		logger.error("Error refreshing axes",e);
	}
	
}
 
开发者ID:eclipse,项目名称:dawnsci,代码行数:18,代码来源:DynamicSliceViewIterator.java

示例14: sanitizeErrorData

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
private ILazyDataset sanitizeErrorData(ILazyDataset errorData) {
	// remove any axes metadata as parent already has them
	if (errorData == null) return null;
	ILazyDataset view = errorData.getSliceView();
	view.clearMetadata(AxesMetadata.class);
	return view;
}
 
开发者ID:eclipse,项目名称:january,代码行数:8,代码来源:ErrorMetadataImpl.java

示例15: testLoader

import org.eclipse.january.metadata.AxesMetadata; //导入依赖的package包/类
@Test
public void testLoader() throws Exception {
	
	Dataset range = DatasetFactory.createRange(LongDataset.class, 10*13*20*20);
	range.setShape(new int[]{10,13,20,20} );
	
	LazyDynamicDataset dataset = getDataset(range,2,"data");
	
	AxesMetadata ax = MetadataFactory.createMetadata(AxesMetadata.class, 4);
	ax.setAxis(0, DatasetFactory.createRange(LongDataset.class, 10));
	ax.setAxis(1, DatasetFactory.createRange(LongDataset.class, 13));
	dataset.addMetadata(ax);
	
	int max = 399;
	
	for (int i = 0 ; i < (10*13); i++) {
		SliceND slice = new SliceND(dataset.getShape());
		int[] shape = dataset.getShape();
		slice.setSlice(0, shape[0]-1, shape[0], 1);
		slice.setSlice(1, shape[1]-1, shape[1], 1);
		IDataset s = dataset.getSlice(slice);
		Assert.assertEquals(max, s.max().intValue());
		max+=400;
		
		AxesMetadata axm = s.getFirstMetadata(AxesMetadata.class);
		
		Assert.assertEquals(axm.getAxis(0)[0].getSlice().getInt(0, 0, 0, 0), shape[0]-1);
		Assert.assertEquals(axm.getAxis(1)[0].getSlice().getInt(0, 0, 0, 0), shape[1]-1);
		
		dataset.refreshShape();
	}
	
	Assert.assertArrayEquals(new int[]{10,13,20,20},dataset.getShape());
	
}
 
开发者ID:eclipse,项目名称:january,代码行数:36,代码来源:LazyDynamicLoaderTest.java


注:本文中的org.eclipse.january.metadata.AxesMetadata类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。