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

gh-107: add all public functions/classes under glass namespace #221

Merged
merged 6 commits into from
Sep 18, 2024

Conversation

Saransh-cpp
Copy link
Member

@Saransh-cpp Saransh-cpp commented Sep 16, 2024

  • All public or user-facing GLASS functionality now falls under the glass module name.
  • Use absolute imports instead of relative imports within the package (PEP8)

Closes: #107
Changed: All the public functions and classes are now under the glass namespace

@Saransh-cpp Saransh-cpp added the maintenance Maintenance: refactoring, typos, etc. label Sep 16, 2024
@coveralls
Copy link

coveralls commented Sep 16, 2024

Pull Request Test Coverage Report for Build 10903745730

Details

  • 16 of 17 (94.12%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.8%) to 55.069%

Changes Missing Coverage Covered Lines Changed/Added Lines %
glass/lensing.py 0 1 0.0%
Totals Coverage Status
Change from base Build 10883249379: 1.8%
Covered Lines: 478
Relevant Lines: 868

💛 - Coveralls

Copy link
Collaborator

@ntessore ntessore left a comment

Choose a reason for hiding this comment

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

A quick grep -nRI 'glass.' glass shows the following additional locations:

glass/lensing.py:9:The :mod:`glass.lensing` module provides functionality for simulating
glass/lensing.py:43:    from glass.shells import RadialWindow
glass/lensing.py:386:    shells : list of :class:`~glass.shells.RadialWindow`
glass/user.py:9:The :mod:`glass.user` module contains convenience functions for users of the
glass/shapes.py:9:The :mod:`glass.shapes` module provides functionality for simulating the
glass/points.py:9:The :mod:`glass.points` module provides functionality for simulating point
glass/points.py:52:    w : :class:`~glass.shells.RadialWindow`
glass/points.py:126:        the :mod:`~glass.points` module, e.g. ``'linear'`` for
glass/fields.py:9:The :mod:`glass.fields` module provides functionality for simulating random
glass/observations.py:9:The :mod:`glass.observations` module provides functionality for simulating
glass/shells.py:9:The :mod:`glass.shells` module provides functions for the definition of
glass/shells.py:95:        >>> from glass.shells import RadialWindow
glass/galaxies.py:9:The :mod:`glass.galaxies` module provides functionality for simulating galaxies
glass/galaxies.py:46:    w : :class:`~glass.shells.RadialWindow`
glass/galaxies.py:212:    glass.observations.tomo_nz_gausserr :

examples/1-basic/cls.npy Outdated Show resolved Hide resolved
@@ -1,4 +1,68 @@
try:
from ._version import __version__, __version_tuple__ # noqa: F401
from glass._version import __version__, __version_tuple__
Copy link
Member

Choose a reason for hiding this comment

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

Isn't version one place where you don't do an absolute import? At least in my experience, but can't find a resource to back this up

Copy link
Member Author

Choose a reason for hiding this comment

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

I use absolute for my projects and it works fine, but I can update this if relative is recommended for versions imports.

Copy link
Member

Choose a reason for hiding this comment

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

Cool, I don't have a strong preference. Would be good if we can find a resource that does 😛

Copy link
Member Author

Choose a reason for hiding this comment

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

Looked around a bit - setuptools_scm suggests using importlib.metadata to obtain version in __init__ file, but scientific-python/cookie suggests doing from ._version import version as __version__ (probably because this works with majority of the build-backends).

Copy link
Member

@paddyroddy paddyroddy Sep 18, 2024

Choose a reason for hiding this comment

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

I'd probably lean toward the scientific-python one, I must have found that convention somewhere!

@Saransh-cpp
Copy link
Member Author

A quick grep -nRI 'glass.' glass shows the following additional locations:

Ah, I thought the modules should still import other modules explicitly so that developers know where the functions are coming from? They can look at the __init__ file too, but it should be fine to have long imports internally. I'll be happy to switch it to the new style tho.

@paddyroddy
Copy link
Member

Ah, I thought the modules should still import other modules explicitly so that developers know where the functions are coming from? They can look at the __init__ file too, but it should be fine to have long imports internally. I'll be happy to switch it to the new style tho.

I would usually do this internally too, makes it easy to know where stuff comes from

@ntessore
Copy link
Collaborator

A quick grep -nRI 'glass.' glass shows the following additional locations:

Ah, I thought the modules should still import other modules explicitly so that developers know where the functions are coming from? They can look at the __init__ file too, but it should be fine to have long imports internally. I'll be happy to switch it to the new style tho.

Modules should import from the true location. Those examples are all user-facing text in the docs.

@Saransh-cpp
Copy link
Member Author

Those examples are all user-facing text in the docs

Oh yes, I missed a few spots. Thank you!

Copy link
Member

@paddyroddy paddyroddy left a comment

Choose a reason for hiding this comment

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

Much simpler, just change that version __init__.py thing and good to go I reckon

@@ -1,4 +1,68 @@
try:
from ._version import __version__, __version_tuple__ # noqa: F401
from glass._version import __version__, __version_tuple__
Copy link
Member

@paddyroddy paddyroddy Sep 18, 2024

Choose a reason for hiding this comment

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

I'd probably lean toward the scientific-python one, I must have found that convention somewhere!

@Saransh-cpp
Copy link
Member Author

Thanks for the review! I'll also wait on @ntessore's approval on this.

Copy link
Collaborator

@ntessore ntessore left a comment

Choose a reason for hiding this comment

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

Great work, this had been stuck in the queue for ages!

@paddyroddy paddyroddy merged commit d075c38 into main Sep 18, 2024
11 checks passed
@paddyroddy paddyroddy deleted the saransh/namespace branch September 18, 2024 15:37
@paddyroddy
Copy link
Member

I've merged this as will need for #232

@Saransh-cpp Saransh-cpp self-assigned this Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance: refactoring, typos, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Functions in glass module
4 participants