Code Monkey home page Code Monkey logo

niondata's People

Contributors

brow71189 avatar cmeyer avatar luc-j-bourhis avatar nion-buildbot avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

niondata's Issues

function_concatenate should preserve data_descriptor of input data

The current implementation uses the default data_descriptor from DataAndMetadata for the result of concatenate. This can lead to unexpected result when concatenating e.g. two sequences, because the result would then be a collection (which is the default behavior of DataAndMetadata).
To decide which data_descriptor to use there are two options:

  1. Use the data_descriptor of the first input xdata. This would match the current behavior for intensity_calibration

  2. Only allow concatenation of xdata with homogeneous data_descriptors and use the common data_descriptor.

The second method would be "cleaner" but is also more restrictive and could cause some confusion for users. On the other hand, concatenating non-homogeneous data is not a well-defined operation so it should maybe not be allowed.

Consider mechanism to track additional data properties such as whether complex is Hermitian

The DataAndMetadata object includes the ability to describe the data type, dimensional usage, and calibrations. But there is no mechanism to track the overall nature of the data array such as whether complex data is Hermitian.

See nion-software/nionswift#242

The Hermitian-ness of the data can be determined programmatically, but it would be time consuming. So having some mechanism of tracking it would be useful.

Also, it might be nice to treat Hermitian-ness as a data type (i.e. complex64-hermitian) but this might be difficult to support when transparently masquerading as an ndarray since ndarray has no such data type.

Storing this as a property in metadata would be another possibility. But two things make this difficult: the first is the abstract design idea that the metadata is not descriptive of the data mechanics; the second is that metadata is stripped during any processing (this behavior is currently being debated; but that's how it works right now).

That leaves adding another descriptive element to DataAndMetadata to describe whether complex data is to be considered Hermitian.

Are there other similar descriptive possibilities other than Hermitian?

Processing functions should not strip metadata from processed xdata.

Right now, some of them at least try to add some sensible dimensional and intensity calibrations to the output data. But all functions in Core.py strip the metadata dict from their inputs.
Processing functions with one input and one output should just copy the metdata to their outputs.
For processing functions with multiple inputs, I'm not sure what the best solution would be. 3 ideas:

  1. Use the metadata from the first input: Very simple but probably the worst solution (still better than the current situation, though)
  2. Add a list of metadata dicts to the output: Also very simple, but can overload the metadata of the output a bit. We already have a lot of stuff in there, and multiplying that might make it even harder for the user to browse through it.
  3. Merge the metadata dicts: This is the most complex, but probably most elegant solution. We would recursively go through the metadata and only put common keys into the result once. If the values of these keys are the same, we just list the values once, otherwise they get turned into a list of values for each input.
    Alternatively we could have the common key, value pairs in one dict and the "unique" ones in a list of dicts as in point 2.

Sequences of color images

I have an issue related to sequences of color images. A minimal reproducible example, that can be typed into the console, is given below.

data = (numpy.random.rand(4, 64, 64, 3) * 255).astype(np.uint8)
data_descriptor = api.create_data_descriptor(is_sequence=True, collection_dimension_count=0, datum_dimension_count=2)
xdata = api.create_data_and_metadata(data, data_descriptor=data_descriptor)
api.library.create_data_item_from_data_and_metadata(xdata)

—— error message (shortened) ——

dimensional_calibration = data_and_metadata.dimensional_calibrations[dimensional_calibration_index]

IndexError: list index out of range

A simple change to the function “function_data_slice” in nion.data.DataAndMetadata.py makes color sequences work. However, this change currently messes up 1d data.

Intermittent test failures in new multi dimensional functions

======================================================================
FAIL: test_function_measure_multi_dimensional_shifts_3d (test.MultiDimensionalProcessing_test.TestMultiDimensionalProcessing) [Test for a 2D collection of 1D data, measure shift of data dimensions along collection axis]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\niondata\niondata\nion\data\test\MultiDimensionalProcessing_test.py", line 1[8](https://github.com/nion-software/niondata/actions/runs/3049104430/jobs/4914843216#step:8:9)5, in test_function_measure_multi_dimensional_shifts_3d
    self.assertTrue(numpy.allclose(result.data, -1.0 * (shifts - shifts[numpy.unravel_index(reference_index, shifts.shape)]), atol=0.5))
AssertionError: False is not true

----------------------------------------------------------------------
Ran 106 tests in 1.34[9](https://github.com/nion-software/niondata/actions/runs/3049104430/jobs/4914843216#step:8:10)s

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.