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

option to include min/max limits on the color field for export_sketchfab #4556

Merged

Conversation

evanoconnor
Copy link

PR Summary

For exporting surfaces to 3D objects there are a few options, for example export_blender and export_sketchfab. export_sketchfab does not include the ability to limit the range of the color field (export_blender does). This PR brings that functionality to export_sketchfab through optional arguments.

PR Checklist

  • [ x ] New features are documented, with docstrings and narrative docs

@welcome
Copy link

welcome bot commented Jun 30, 2023

Hi! Welcome, and thanks for opening this pull request. We have some guidelines for new pull requests, and soon you'll hear back about the results of our tests and continuous integration checks. Thank you for your contribution!

@neutrinoceros
Copy link
Member

Please fix the indentation. At the moment your code is not valid Python (see https://results.pre-commit.ci/run/github/88776493/1688125829.Xtb3gkPGTg6Woa7ABHKa8Q)

@matthewturk
Copy link
Member

@evanoconnor Thank you for this pull request! I think this is a good addition, and I appreciate you adding it to the code base. The changes suggested are pretty minor I think, and I'm happy to help out if you'd like to get it across the finish line.

@evanoconnor
Copy link
Author

ok, I'm a little bit unsure about the error after the last commit [d736bfc]. It worked on my install, but I think I'm missing something about *,

@neutrinoceros
Copy link
Member

pre-commit.ci autofix

@neutrinoceros neutrinoceros added the enhancement Making something better label Jul 1, 2023
Copy link
Member

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

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

Nice progress, now the code seems functional. I think I see a couple ways this could be simplified, though maybe I'm just missing something. Any way, here are a couple questions !

Comment on lines 2505 to 2507
cs = [float(field) for field in cs]
cs = np.array(cs)
mi = cs.min()
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand this change. What's the gain here, compared to mi = cs.min() ?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not 100% (this is just a copy of the max/min treatment for the export_obj subroutine). I'm guessing this gets rid of the units though?

Copy link
Member

Choose a reason for hiding this comment

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

ah ! if dropping units is the intention here it should probably just be mi = np.asarray(cs).min()

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fairly baffled by this (and export_obj, so this comment isn't directed at you, @evanoconnor :) ). From what i can tell the input cs to this function will always be an array? so cs = [float(field) for field in cs] a few lines above this will iterate over every element and individually cast to float just to convert back to an array afterwards? that seems not great.... am I missing something?

Copy link
Member

Choose a reason for hiding this comment

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

I believe this is indeed to drop units, and possibly it's to do some conversion away from numpy arrays, because of some business with the exporting, but I cannot recall.

Copy link
Author

Choose a reason for hiding this comment

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

cs is used a bit further down to construct the color scale from 0 to 1. So I guess this then:

            cs = np.asarray(cs)
            mi = cs.min()

before deciding on the best way here, what is the general practice for units? should the color_field_max and color_field_max have units at the onset, that would fail here because cs drops the units and mi and ma would retain them.

Copy link
Member

Choose a reason for hiding this comment

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

yt's interface regarding scalar values with units isn't exactly consistent at the moment. In many places, we expect floats where we could in principle support passing quantities.
I think it's fine that color_field_min and color_field_max only support float values for now. We can always add support for quantities in the future.

Agreed that cs = np.asarray(cs) is the most robust and efficient way to drop units.

yt/data_objects/construction_data_containers.py Outdated Show resolved Hide resolved
@matthewturk matthewturk merged commit 1edfb8f into yt-project:main Jul 20, 2023
12 checks passed
@welcome
Copy link

welcome bot commented Jul 20, 2023

Hooray! Congratulations on your first merged pull request! We hope we keep seeing you around! 🎆

@matthewturk
Copy link
Member

@evanoconnor Would you consider adding yourself to the yt paper? https://github.com/yt-project/yt-4.0-paper/#authorship-policy

@neutrinoceros neutrinoceros added this to the 4.3.0 milestone Jul 21, 2023
@evanoconnor
Copy link
Author

@matthewturk Thanks, but I don't quite think this warrants authorship, and I don't have the time to help with the paper (plus it seems like it is nearing the end!) I am looking forward to have such a resource though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Making something better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants