Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Python Example use_case_02.py with additional example codes #423

Open
wants to merge 403 commits into
base: develop
Choose a base branch
from

Conversation

mhitzem
Copy link
Contributor

@mhitzem mhitzem commented Aug 11, 2021

  • Generates a new csv file with random data (fake scalar data)
  • Data from file is read and put into uint32 and float32 arrays and added to AttributeMatrix and DataContainer

imikejackson and others added 30 commits August 26, 2019 10:17
* Replace malloc/free with new/delete[]
* Reintroduce SimpleITKExplicit library to solve symbol loading issues on macOS.
* Fix allocation errors in DataArray and StructArray

Signed-off-by: Michael Jackson <[email protected]>
…zSoftware#376)

* Updates to codes to expose double precision versions where needed
* MatrixMath is now mostly templated to work on any POD.
* Fix return type in MatrixMath and remove spurious newline in ImportHDF5Dataset
* More Fixes and Updates to Quaternion related classes.

Signed-off-by: Michael Jackson <[email protected]>
…rtzSoftware#379)

Copying a DataContainerReader filter to the clipboard in SVPipelineView no longer copies the entire pipeline that was written instead. This is done by taking advantage of JsonFilterParametersWriter::setExpandReaderFilters(bool) to avoid modifying behavior used to write DREAM.3D files.

Signed-off-by: Matthew Marine <[email protected]>
* Added const to appropriate DataArray functions

* NeighborList::writeH5Data needed some additional changes since it was
trying to modify a member variable

* Added const to appropriate Geometry functions

* LinkedDataContainerSelectionWidget needed the IGeometry include to work

* Added const to DynamicTableData::getTableData()

* Added const to appropriate functions in AM, DC, and DCA classes
…changes

Methods exposed to Python bindings that were changed to be a "const" method needed
to have the CONST_METHOD argument added to the macro.

Signed-off-by: Michael Jackson <[email protected]>
…sues

    commit 4166131
    Author: Michael Jackson <[email protected]>
    Date:   Wed Oct 30 14:52:10 2019 -0400

        Fix bug using std::accumulate due to casting issue.

        Passing in "1" will force the computation to be done in int32_t. When using large
        Tuple dimensions we will over flow.

        Signed-off-by: Michael Jackson <[email protected]>

    commit b216f5a
    Author: Michael Jackson <[email protected]>
    Date:   Tue Oct 29 17:05:05 2019 -0400

        Add missing include directive <memory> for shared_ptr<> access.

        Updated some other code areas with better documentation strings
        Updated some code sections to be more consistent with use of type aliases.

        Signed-off-by: Michael Jackson <[email protected]>

    commit d16dc31
    Author: Michael Jackson <[email protected]>
    Date:   Tue Oct 29 13:37:16 2019 -0400

        Update codes to latest const correctness changes

        Signed-off-by: Michael Jackson <[email protected]>

    commit 643d99b
    Merge: f5958ad c055656
    Author: Michael Jackson <[email protected]>
    Date:   Tue Oct 29 09:11:37 2019 -0400

        Fix compiler errors due to PYBIND_11 macros not being updated to API changes

        * develop:
          Fix compiler errors due to PYBIND_11 macros not being updated to API changes
          Feature/const (BlueQuartzSoftware#380)

        # Conflicts:
        #   Source/SIMPLib/DataArrays/StatsDataArray.h
        #   Source/SIMPLib/DataArrays/StringDataArray.h
        #   Source/SIMPLib/DataContainers/AttributeMatrix.h
        #   Source/SIMPLib/DataContainers/DataContainerArray.h
        #   Source/SIMPLib/Geometry/IGeometry.h
        #   Source/SIMPLib/Geometry/IGeometry2D.h
        #   Source/SIMPLib/Geometry/IGeometryGrid.h
        #   Source/SIMPLib/Geometry/ImageGeom.h
        #   Source/SVWidgetsLib/FilterParameterWidgets/LinkedDataContainerSelectionWidget.cpp

    commit f5958ad
    Author: Michael Jackson <[email protected]>
    Date:   Mon Oct 28 13:37:21 2019 -0400

        Feature/const (BlueQuartzSoftware#380)

        * Added const to appropriate DataArray functions

        * NeighborList::writeH5Data needed some additional changes since it was
        trying to modify a member variable

        * Added const to appropriate Geometry functions

        * LinkedDataContainerSelectionWidget needed the IGeometry include to work

        * Added const to DynamicTableData::getTableData()

        * Added const to appropriate functions in AM, DC, and DCA classes

        Signed-off-by: Michael Jackson <[email protected]>

    commit 4cb6eec
    Author: Michael Jackson <[email protected]>
    Date:   Fri Oct 25 15:18:25 2019 -0400

        Address feedback from code review.

        Remove static const from constants.h
        Fix duplicate variable names in experimental file.

    commit a292511
    Author: Michael Jackson <[email protected]>
    Date:   Fri Oct 25 12:35:24 2019 -0400

        Add conditional #pragma for clang diagnostics

        Signed-off-by: Michael Jackson <[email protected]>

    commit 6f73a64
    Author: Michael Jackson <[email protected]>
    Date:   Fri Oct 25 12:12:57 2019 -0400

        Fixing compiler errors on MSVC Platform

        Signed-off-by: Michael Jackson <[email protected]>

    commit 316d395
    Author: Michael Jackson <[email protected]>
    Date:   Fri Oct 25 11:53:57 2019 -0400

        Fix DOxygen comments that got munged up in some find/replace operation

        Signed-off-by: Michael Jackson <[email protected]>

    commit 693c2fe
    Author: Michael Jackson <[email protected]>
    Date:   Fri Oct 25 11:43:17 2019 -0400

        Fix compiler warnings about overriding a virtual method without using override keyword

        Signed-off-by: Michael Jackson <[email protected]>

    commit 7775443
    Author: Michael Jackson <[email protected]>
    Date:   Thu Oct 24 12:40:33 2019 -0400

        Improve generated CPP code to modern standards

        Signed-off-by: Michael Jackson <[email protected]>

    commit 4a50ac7
    Author: Michael Jackson <[email protected]>
    Date:   Thu Oct 24 12:40:14 2019 -0400

        Add a clang pragma to quiet a warning about using std::move.

        Signed-off-by: Michael Jackson <[email protected]>

    commit ad86eb0
    Author: Michael Jackson <[email protected]>
    Date:   Thu Oct 24 09:24:09 2019 -0400

        Update Messages classes and remove Python Wrapping from pure virtual class

        Signed-off-by: Michael Jackson <[email protected]>

    commit 051a664
    Author: Michael Jackson <[email protected]>
    Date:   Wed Oct 23 14:42:52 2019 -0400

        Fix warnings about returning const QString as a value instead of a reference.

        Warnings are fixed by changing from "const QString" to "QString"

        Signed-off-by: Michael Jackson <[email protected]>

    commit 66bf335
    Author: Michael Jackson <[email protected]>
    Date:   Wed Oct 23 14:03:47 2019 -0400

        Merge and Compile error fixes

        Signed-off-by: Michael Jackson <[email protected]>

    commit 4536233
    Author: Michael Jackson <[email protected]>
    Date:   Thu Jun 27 18:02:45 2019 -0400

        Fix more pass by reference for POD types

        Signed-off-by: Michael Jackson <[email protected]>

    commit 3fb6d31
    Author: Michael Jackson <[email protected]>
    Date:   Thu Jun 27 10:49:58 2019 -0400

        Resolving merge conflicts

        Signed-off-by: Michael Jackson <[email protected]>

    commit 8e6826d
    Author: Michael Jackson <[email protected]>
    Date:   Mon Jun 24 18:06:26 2019 -0400

        Fixing code based on feed back from PR

        Signed-off-by: Michael Jackson <[email protected]>

    commit 3995ead
    Author: Michael Jackson <[email protected]>
    Date:   Fri Jun 21 14:24:15 2019 -0400

        Fix pass by const reference for POD types

        In the last pass at removing the macros POD types were mistakenly passed by
        const reference instead of by value. These have all been fixed to pass by value.

        Signed-off-by: Michael Jackson <[email protected]>

    commit 71df37a
    Author: Michael Jackson <[email protected]>
    Date:   Thu Jun 13 18:14:59 2019 -0400

        Massive code modifications to clean up and reduce macro clutter

        * Remove use of all SIMPL_* macros replacing with actual C++ code
        * Remove the include directive to DataContainerArray in AbstractFilter instead using a forward declaration and alias
        * Add needed include directives or forward declarations to all effected classes

        Signed-off-by: Michael Jackson <[email protected]>

    commit f6ba40d
    Author: Michael Jackson <[email protected]>
    Date:   Thu Jun 13 18:57:23 2019 -0400

        Transfer some SIMPL_* macros into the Pybind11 macro section

        This is needed because the codescraper algorithm looks for four specific macros in order
        to determine the proper c++ and python code to generate. The same macros have been
        defined in the SIMPLPythonMacros.h header file.

        Signed-off-by: Michael Jackson <[email protected]>

    commit 35b2d0e
    Author: Michael Jackson <[email protected]>
    Date:   Tue Jun 11 18:19:16 2019 -0400

        Wrap the Python wrapping macros in a #define for SIMPL_ENABLE_PYTHON

        This is done because SIMPLibSetGetMacros is going away eventually and we need to separate
        out the still needed macros that help generate the python bindings.

        Signed-off-by: Michael Jackson <[email protected]>

    commit ca158c3
    Author: Michael Jackson <[email protected]>
    Date:   Tue Jun 11 18:05:43 2019 -0400

        Add compiler define if SIMPL_ENABLE_PYTHON is turned on.

        Update clang-format to NOT sort the includes.

        Signed-off-by: Michael Jackson <[email protected]>

    Signed-off-by: Michael Jackson <[email protected]>
* Default constructor still expands reader filters.
* The constructor accepting filename, pipeline name, and number of filters once again does not expand reader filters.  Booleans default construct to false.

Signed-off-by: Matthew Marine <[email protected]>
…lueQuartzSoftware#378)

* Add filter that generates a tilt series of images from an ImageGeom

* Creating Unit test that only tests the basic functionality

A deeper unit test that has exemplar output images needs to be created.

* Address use of static const.

updates BlueQuartzSoftware#378 

* Added check to prevent accessing unallocated array elements

* GenerateTiltSeries::generateGrid() could try to create a grid
coordinates array with 0 elements and then access it depending on
the user input for the spacing.
* Changed the axis constants in GenerateTiltSeries to be static
constexpr

* Add another array to the debugged vertex array that stores the FeatureIds.

This allows the developer to more easily debug the rotated geometries
complete with the proper data.

* Added parameter for the prefix of the output data containers

* Changed constants to be constexpr

* Ran clang-format

* Update codes to latest API Changes.

* Adjusted some debugging data arrays that get created.

* Rewrite Grid generation be specific for X, Y or Z Axis.

The generic versions were to difficult and obtuse to get working.

* Added test for GenerateTiltSeries filter

* Compares against GenerateTiltSeriesTest.dream3d from DREAM3D_Data repo

* Added copyright notice

* Ran clang-format

Signed-off-by: Michael Jackson <[email protected]>
* Fix compile bug on gcc where sqrtf isn't in std namespace

* For gcc, sqrtf is not in the std namespace but sqrt is

* Fixed compile bug for gcc with static constexpr variable
These were meant for debugging only but may be used in a future version as a user option

Signed-off-by: Michael Jackson <[email protected]>
* m_InitValue is now set to the initValue parameter instead of static_cast<T>(0)

Signed-off-by: Matthew Marine <[email protected]>
…f strings (BlueQuartzSoftware#384)

* Added static function for creating a Requirement with a vector of strings

* Changed usage of QVector<AttributeMatrix::Type> to AttributeMatrix::Types
This change removes compiler warnings about redeclaring some of the macros. In order to truly
fix the issue the developers would need to understand that there is an exact order
when including <math.h> or <cmath>. With this change we can just include SIMPLibMath.h
and not have to worry about the proper include order

Signed-off-by: Michael Jackson <[email protected]>
* Moved RotateSampleRefFrame filter to SIMPL Core Filters

* Fixed include error

* Fixed compile error for GCC

* Fix Python binding compile error

* Updated copyright info

* Add missing include directives (strictly)

Cleanup warnings on change of precision casts.

Signed-off-by: Michael Jackson <[email protected]>
Signed-off-by: Michael Jackson <[email protected]>
…d of QMetaProperty (BlueQuartzSoftware#386)

* Update Filter Parameter Widgets to use std::function callbacks instead of QMetaProperty

Signed-off-by: Michael Jackson <[email protected]>
…re#387)

Explicitly instantiating each variation of DataArray<T>

This should cut down on compile times (somewhat).
Add MarkDown as supported InfoStringFormat for DataArray<>
Fixing some typos in the Float Comparison Macros

Signed-off-by: Michael Jackson <[email protected]>
* CreateGeometry uses uint64 arrays for Edge List, Triangle List, etc.
* datacheck() searched for uint64 arrays, but the GUI only allowed the user
to input int64 arrays
JDuffeyBQ and others added 18 commits May 5, 2021 13:45
* Declaring all bound classes before adding methods allows the
right name to be used in docstrings

Signed-off-by: Jared Duffey <[email protected]>
The data arrays that were set for things such as the vertex shared list were not
being removed from the source Attribute Matrix when the user selected to have the
data MOVED instead of COPIED.

Signed-off-by: Michael Jackson <[email protected]>
Check for &, :, / or \ as those characters can cause issues down the road when written
to disk.
Minor include cleanup via removing headers that are not needed.

Signed-off-by: Michael Jackson <[email protected]>
What we found out today: You can call a member function of a null pointer as long
 as the function never dereferences 'this'. Now we know.

Signed-off-by: Michael Jackson <[email protected]>
Signed-off-by: Michael Jackson <[email protected]>
* Improves python docstrings
* More type safe for C++ side

Signed-off-by: Jared Duffey <[email protected]>
* Casting functions would create a python object and then
immediately destroy it upon return. Future accesses would then
cause a crash
* Improved some of the generated docstrings for typecasters
* Changed assert to static_assert for QChar size
* Added several new type casters to cover previously
unconvertable types
* Fixed some type conversion issues for unbound sub types

Signed-off-by: Jared Duffey <[email protected]>
* Allows for split declaration/definition before the macro based
bindings
* Added several more bound types

Signed-off-by: Jared Duffey <[email protected]>
* Uses mypy stubgen

Signed-off-by: Jared Duffey <[email protected]>
Copy link
Contributor

@imikejackson imikejackson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could we also add an argument "--output_dir" to the main args that allows the user to set where all of the output files are created. Be sure to flow that through all needed parts of the code.

Wrapping/Python/Examples/use_case_02.py Show resolved Hide resolved
Wrapping/Python/Examples/use_case_02.py Outdated Show resolved Hide resolved
Wrapping/Python/Examples/use_case_02.py Outdated Show resolved Hide resolved

#Creates arrays from data with shape of (# of vertices x 1)
uintarr = np.ndarray(shape=(37989, 1), dtype=np.uint32, buffer=uints)
floatarr = np.ndarray(shape=(37989, 1), dtype=np.float32, buffer=f32s)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the numVerts variable from above instead of the 37989 hard coded value.

Wrapping/Python/Examples/use_case_02.py Outdated Show resolved Hide resolved
Wrapping/Python/Examples/use_case_02.py Outdated Show resolved Hide resolved
@imikejackson imikejackson changed the title Adding scalar data to XYZ coordinate Improve Python Example use_case_02.py with additional example codes Aug 12, 2021
@imikejackson imikejackson added Enhancement Code added that makes life easier good first issue labels Aug 12, 2021
Wrapping/Python/Examples/use_case_02.py Outdated Show resolved Hide resolved
Wrapping/Python/Examples/use_case_02.py Outdated Show resolved Hide resolved
am.addOrReplaceAttributeArray(f32arr)

# Add AttributeMatirx to DataContainer
dc.addOrReplaceAttributeMatrix(am)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if you can add the DREAM3D filter "apply_transformation_to_geometry" which is in the DREAM3DReview plugin. Take a look at https://github.com/dream3d/DREAM3DReview/blob/develop/Test/Python/Apply_Transformation_To_Geometry.py file for inspiration.

In that example we are using a transformation matrix but see if you can figure out how to use just a scaling factor in each direction. Try out a scaling factor of 10x in each direction just to make it obvious when the data is viewed.

Write out the dream3d file before the transformation and after then use ParaView to view the results and verify that you have successfully scaled the vertices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Code added that makes life easier good first issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants