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

issue-250-ridge-transforms #298

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Hojat-Shirmard
Copy link

Search for "hjt" in the file; you'll see I've added lines of code in four different places.

Search for "hjt" in the file; you'll see I've added lines of code in four different places.
@michaelchin michaelchin marked this pull request as draft October 24, 2024 03:19
@michaelchin michaelchin changed the title First commit issue-250-ridge-transforms Oct 24, 2024
@michaelchin
Copy link
Contributor

@Hojat-Shirmard

moved the two functions to the end of the file and fixed the indentation.
added"ridge_transforms" as property(return self.ridges + self.transforms), similar to this https://github.com/GPlates/gplately/blob/bea66aaff046fa7d08e33c94c41b63695f8ecbe9/gplately/plot.py#L383-L387
@Hojat-Shirmard
Copy link
Author

Hi @michaelchin
I made a second commit considering your requested changes. To test the code, should I add plot.plot.ridge_transforms to the code you shared and run it in the Jupyter notebook?

@michaelchin
Copy link
Contributor

Hi @michaelchin I made a second commit considering your requested changes. To test the code, should I add plot.plot.ridge_transforms to the code you shared and run it in the Jupyter notebook?

yes, add plot_ridge_transform() funciton call and comment out other plotting code to see the result more clearly.

And you can see your code changes here https://github.com/GPlates/gplately/pull/298/files. there are still errors in the code changes.

@Hojat-Shirmard
Copy link
Author

How can I know where the errors are?

@michaelchin
Copy link
Contributor

How can I know where the errors are?

Have you tried to click this link https://github.com/GPlates/gplately/pull/298/files?

if you did, see the screenshot below for example.

You need to make sure the changes are intended. And only make changes when it is necessary.

Screenshot 2024-11-02 at 3 56 22 PM

@Hojat-Shirmard
Copy link
Author

I reckon I need to create a new environment in Anaconda and install my modified branch to check if it’s working properly, right?
I've also passed some courses on YouTube and learned a bit about Docker, so if there are any instructions or steps to follow with Docker, I’d be happy to try that as well.

@Hojat-Shirmard
Copy link
Author

I added logger.debug
I added the "ridge_transforms" attribute, but the result is not correct!
plot

@jcannon-gplates
Copy link
Contributor

Maybe it's because the @property decorator is missing. See Michael's example above...

 @property 
 def topological_plate_boundaries(self): 
     if self._topological_plate_boundaries is None: 
         self.update_time(self.time) 
     return self._topological_plate_boundaries

You can see here how properties are added.

@Hojat-Shirmard
Copy link
Author

Hi @jcannon-gplates
Thank you for your quick response!
I just fixed the property, and here is the result:
plot2

@jcannon-gplates
Copy link
Contributor

It looks like you're using self._topological_plate_boundaries. That will work since it'll generate self.ridges and self.transforms if those attributes don't exist yet.

However, it might be better to do something like...

    @property
    def ridge_transforms(self):
        """Combine ridges and transforms into one feature set."""
        if self.time is None:
            raise ValueError(
                "No topologies have been resolved. Set `PlotTopologies.time` to construct them."
            )
        logger.debug("Returning ridge_transforms property.")
        return self.ridges + self.transforms

...where I've replaced...

        if self._topological_plate_boundaries is None:
            logger.debug("Accessing ridge transforms - updating topological plate boundaries.")
            self.update_time(self.time)

...with...

        if self.time is None:
            raise ValueError(
                "No topologies have been resolved. Set `PlotTopologies.time` to construct them."
            )

...because if the time hasn't been set (in either __init__ or with self.time = ...), and hence self.time (as well as self._topological_plate_boundaries) is None, then self.update_time(self.time) will fail here.

@GPlates/gplately-dev, does this sound right? I think self.update_time() probably should only be called on setters (like self.anchor_plate_id = ...). Getters should already be up-to-date (since update_time() has already been called behind the scenes whenever the class state changed, via setters, etc). Getters (that rely on variables updated by update_time()) should perhaps instead raise an error (if the time has not been set yet). My understanding is the user should eventually set the time if they want to access certain functionalities of the class. For example, self.ridges and self.transforms don't exist if the user has not yet set the time, so an error should be raised if they try to access them.

@Hojat-Shirmard
Copy link
Author

Thank you so much! I just applied your comment.

@michaelchin
Copy link
Contributor

Thanks @jcannon-gplates and @Hojat-Shirmard

Just out of curiosity, what was the reason of these two lines got removed?

Screenshot 2024-11-26 at 5 08 13 pm

@Hojat-Shirmard
Copy link
Author

I think I messed up—sorry about that! I'll fix it now.

@michaelchin
Copy link
Contributor

@Hojat-Shirmard Can you add other properties and functions which were mentioned in #250? And also add the warning and debug messages mentioned in #250. Thanks.

@Hojat-Shirmard
Copy link
Author

@michaelchin, Did you mean this comment?
#250 (comment)

@michaelchin
Copy link
Contributor

@michaelchin, Did you mean this comment? #250 (comment)

Could you please read #250? There are a few comments regarding what need to be done. Thanks.

@Hojat-Shirmard
Copy link
Author

I added misc_transforms

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

Successfully merging this pull request may close these issues.

3 participants