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

Remove duplicate methods #6291

Merged
merged 5 commits into from
Nov 14, 2022

Conversation

wd60622
Copy link
Contributor

@wd60622 wd60622 commented Nov 11, 2022

What is this PR about?
Noticed some duplicated methods in the pymc/model.py file mentioned in issue here.
Removed the duplication and tried to improve the docstrings

Checklist

Major / Breaking Changes

  • Using keyword seed for initial point no longer supported

Bugfixes / New features

  • NA

Docs / Maintenance

  • More consistent seeding argument with random_seed
  • Removed duplication function and method names throughout the package

pymc/model.py Outdated
Comment on lines 1004 to 1005
random_seed : SeedSequenceSeed, default None
Seed(s) for generating initial point from the model. Used in pymc.aesaraf.reseed_rngs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is the correct indication of this type in the docstring. Kind of long created type. i.e.

SeedSequenceSeed = Optional[Union[int, Sequence[int], np.ndarray, np.random.SeedSequence]]

Also mentioned the function that this value is fed into. Not sure how that renders atm.

Copy link
Member

Choose a reason for hiding this comment

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

Looks about right (from here)

grafik

@codecov
Copy link

codecov bot commented Nov 11, 2022

Codecov Report

Merging #6291 (9c74115) into main (5d7283e) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6291      +/-   ##
==========================================
+ Coverage   94.12%   94.14%   +0.02%     
==========================================
  Files         111      111              
  Lines       23861    23847      -14     
==========================================
- Hits        22458    22450       -8     
+ Misses       1403     1397       -6     
Impacted Files Coverage Δ
pymc/model.py 90.32% <100.00%> (+0.63%) ⬆️
pymc/smc/kernels.py 97.37% <100.00%> (ø)

@@ -1259,34 +1265,6 @@ def set_data(

shared_object.set_value(values)

def initial_point(self, seed=None) -> Dict[str, np.ndarray]:
Copy link
Member

@ricardoV94 ricardoV94 Nov 11, 2022

Choose a reason for hiding this comment

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

I think I probably caused this when trying to reorder the methods a bit more logically. There is a shape_from_dims below the initial point related methods which makes more sense above, close to the other coord/dims related methods.

I would therefore delete the repeated methods above and not these below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright. I will reorder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put after the dim/coords methods but before set_data. Thought that made enough sense

pymc/model.py Outdated
@@ -1137,6 +1101,48 @@ def set_dim(self, name: str, new_length: int, coord_values: Optional[Sequence] =
self.dim_lengths[name].set_value(new_length)
return

@property
def test_point(self) -> Dict[str, np.ndarray]:
Copy link
Member

Choose a reason for hiding this comment

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

We can get rid of this deprecated property as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@michaelosthege michaelosthege left a comment

Choose a reason for hiding this comment

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

Looks like this is ready to merge, right @ricardoV94 ?

pymc/model.py Outdated
Comment on lines 1004 to 1005
random_seed : SeedSequenceSeed, default None
Seed(s) for generating initial point from the model. Used in pymc.aesaraf.reseed_rngs
Copy link
Member

Choose a reason for hiding this comment

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

Looks about right (from here)

grafik

@michaelosthege michaelosthege added maintenance major Include in major changes release notes section labels Nov 14, 2022
@michaelosthege michaelosthege merged commit 24888ac into pymc-devs:main Nov 14, 2022
@wd60622 wd60622 deleted the duplicate_initial_point_method branch November 14, 2022 19:37
wrongu pushed a commit to wrongu/pymc that referenced this pull request Dec 1, 2022
* remove dups, add type hints, and docstrings
* replacing references to old code
* reorder and reword
* deprecate the "test_point" method
* fix NameError. got to work locally
@bmorris3
Copy link

Was it intentional/necessary to change the argument seed to random_seed? This leads to lots of breaks in things downstream.

@michaelosthege
Copy link
Member

it was an intentional change, but next time we should go for a backwards compatible approach with a deprecation warning..

@wd60622
Copy link
Contributor Author

wd60622 commented Jan 11, 2023

Was it intentional/necessary to change the argument seed to random_seed? This leads to lots of breaks in things downstream.

Can you be specific with "lots" of breaking changes?

Is there something that isn't covered in the tests? Or were your solutions just a grep replace? Replacements in internal code or only personal written sections?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance major Include in major changes release notes section
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants