René's URL Explorer Experiment


Title: Draft abc.SLM feedback wanted · Issue #302 · python-microscope/microscope · GitHub

Open Graph Title: Draft abc.SLM feedback wanted · Issue #302 · python-microscope/microscope

X Title: Draft abc.SLM feedback wanted · Issue #302 · python-microscope/microscope

Description: I implemented a draft of an abc.SLM in here. Very much like abc.DM Code below. Any comments or feedback? class SpatialLightModulator(TriggerTargetMixin, Device, metaclass=abc.ABCMeta): """Base class for Spatial Light Modulators (SLM). Th...

Open Graph Description: I implemented a draft of an abc.SLM in here. Very much like abc.DM Code below. Any comments or feedback? class SpatialLightModulator(TriggerTargetMixin, Device, metaclass=abc.ABCMeta): """Base clas...

X Description: I implemented a draft of an abc.SLM in here. Very much like abc.DM Code below. Any comments or feedback? class SpatialLightModulator(TriggerTargetMixin, Device, metaclass=abc.ABCMeta): ""...

Opengraph URL: https://github.com/python-microscope/microscope/issues/302

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Draft abc.SLM feedback wanted","articleBody":"I implemented a draft of an abc.SLM in [here](https://github.com/juliomateoslangerak/microscope/tree/implement_SLM). Very much like abc.DM\r\n\r\nCode below. Any comments or feedback?\r\n\r\n```python\r\nclass SpatialLightModulator(TriggerTargetMixin, Device, metaclass=abc.ABCMeta):\r\n    \"\"\"Base class for Spatial Light Modulators (SLM).\r\n\r\n    This class is very similar to the Deformable Mirrors abc. We are trying\r\n    to keep nomenclature consistent. The main differences are that the shape\r\n    of the patterns are different and that we need to provide wavelengths\r\n    along the patterns.\r\n\r\n    Similarly to deformable mirrors, there is no method to reset\r\n    or clear a deformable mirror. For the sake of uniformity, it is better for\r\n    python-microscope users to pass the pattern they want, probably a\r\n    pattern that flattens the SLM.\r\n\r\n    The private properties `_patterns` and `_pattern_idx` are\r\n    initialized to `None` to support the queueing of patterns and\r\n    software triggering.\r\n    \"\"\"\r\n\r\n    @abc.abstractmethod\r\n    def __init__(self, **kwargs) -\u003e None:\r\n        super().__init__(**kwargs)\r\n        self._patterns: typing.Optional[numpy.ndarray] = None\r\n        self._pattern_idx: int = -1\r\n        self._wavelengths: typing.Optional[typing.List[int]] = None\r\n\r\n    @abc.abstractmethod\r\n    def _get_shape(self) -\u003e typing.Tuple[int, int]:\r\n        \"\"\"Get the shape of the SLM in pixels as a (width, height) tuple.\"\"\"\r\n        raise NotImplementedError\r\n\r\n    def get_shape(self) -\u003e typing.Tuple[int, int]:\r\n        \"\"\"Return a tuple of `(width, height)` corresponding to the shape of the SLM\"\"\"\r\n        return self._get_shape()\r\n\r\n    def _validate_patterns(self, patterns: numpy.ndarray, wavelengths: typing.Union[list[int], int]) -\u003e None:\r\n        \"\"\"Validate the shape of a series of patterns.\r\n\r\n        Only validates the shape of the patterns, not if the values\r\n        are actually in the [0 1] range.  If some hardware is unable\r\n        to handle values outside their defined range (most will simply\r\n        clip them), then it's the responsibility of the subclass to do\r\n        the clipping before sending the values.\r\n\r\n        \"\"\"\r\n        if 2 \u003e patterns.ndim \u003e 3:\r\n            raise ValueError(\r\n                \"PATTERNS has %d dimensions (must be 2 or 3)\" % patterns.ndim\r\n            )\r\n\r\n        if patterns.ndim == 3:\r\n            if not isinstance(wavelengths, list) or len(wavelengths) != patterns.shape[0]:\r\n                raise ValueError(\r\n                    \"The length of the wavelengths list %d does not match the number of patterns to load %d\"\r\n                    % (len(wavelengths), patterns.shape[0],)\r\n                )\r\n        elif not isinstance(wavelengths, int):\r\n            raise ValueError(\r\n                \"The wavelength should be an integer when loading a single pattern\"\r\n            )\r\n\r\n        if (patterns.shape[-2], patterns.shape[-1]) != self.get_shape():\r\n            raise ValueError(\r\n                \"PATTERNS shape %s does not match the SLM's shape %s\"\r\n                % ((patterns.shape[-2], patterns.shape[-1],), self.get_shape(),)\r\n            )\r\n\r\n    @abc.abstractmethod\r\n    def _do_apply_pattern(self, pattern: numpy.ndarray, wavelength: int) -\u003e None:\r\n        raise NotImplementedError()\r\n\r\n    def apply_pattern(self, pattern: numpy.ndarray, wavelength: int) -\u003e None:\r\n        \"\"\"Apply this pattern.\r\n\r\n        Args:\r\n            pattern: A 'XY' ndarray with the phases to be loaded into the SLM. The phases have to be\r\n            in the range [0, 1]. 0=0pi and 1=2pi\r\n            wavelength: The wavelength to which the SLM has to be calibrated for that pattern\r\n\r\n        Raises:\r\n            microscope.IncompatibleStateError: if device trigger type is\r\n                not set to software.\r\n\r\n        \"\"\"\r\n        if self.trigger_type is not microscope.TriggerType.SOFTWARE:\r\n            # An alternative to error is to change the trigger type,\r\n            # apply the pattern, then restore the trigger type, but\r\n            # that would clear the queue on the device.  It's better\r\n            # to have the user specifically do it.  See issue #61.\r\n            raise microscope.IncompatibleStateError(\r\n                \"apply_pattern requires software trigger type\"\r\n            )\r\n        self._validate_patterns(pattern, [wavelength])\r\n        self._do_apply_pattern(pattern, wavelength)\r\n\r\n    def queue_patterns(self, patterns: numpy.ndarray, wavelengths: typing.List[int]) -\u003e None:\r\n        \"\"\"Send a set of patterns to the SLM.\r\n\r\n        Args:\r\n            patterns: An `NXY` elements array of phase values in the range\r\n            [0, 1]. 0=0pi and 1=2pi. N is the number of phases to add the queue\r\n            wavelengths: A list of wavelengths (in nm) of length N\r\n\r\n        A convenience fallback is provided for software triggering is provided.\r\n\r\n        \"\"\"\r\n        self._validate_patterns(patterns, wavelengths)\r\n        self._patterns = patterns\r\n        self._wavelengths = wavelengths\r\n        self._pattern_idx = -1  # none is applied yet\r\n        # TODO: What is the function to run the patterns in the queue? enable?\r\n\r\n    def _do_trigger(self) -\u003e None:\r\n        \"\"\"Convenience fallback.\r\n\r\n        This only provides a convenience fallback for devices that\r\n        don't support queuing multiple patterns and software trigger,\r\n        i.e., devices that take only one pattern at a time.  This is\r\n        not the case of most devices.\r\n\r\n        Devices that support queuing patterns, should override this\r\n        method.\r\n\r\n        .. todo::\r\n\r\n            Instead of a convenience fallback, we should have a\r\n            separate mixin for this.\r\n\r\n        \"\"\"\r\n        if self._patterns is None:\r\n            raise microscope.DeviceError(\"no pattern queued to apply\")\r\n        self._pattern_idx += 1\r\n        self.apply_pattern(self._patterns[self._pattern_idx, :], self._wavelengths[self._pattern_idx])\r\n\r\n    def trigger(self) -\u003e None:\r\n        \"\"\"Apply the next pattern in the queue.\"\"\"\r\n        # This is just a passthrough to the TriggerTargetMixin class\r\n        # and only exists for the docstring.\r\n        return super().trigger()\r\n```","author":{"url":"https://github.com/juliomateoslangerak","@type":"Person","name":"juliomateoslangerak"},"datePublished":"2024-06-11T15:36:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/302/microscope/issues/302"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:7031415c-ff42-ad0b-845e-b2a52d6ea545
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAB92:25DF2:C809AD:10371F3:699200A0
html-safe-nonce6c73b1d965b124e0475d2a989ffad12e06ecc18079aa2731cb58d4500eb3e66a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQjkyOjI1REYyOkM4MDlBRDoxMDM3MUYzOjY5OTIwMEEwIiwidmlzaXRvcl9pZCI6IjczMDYyMjIxNjUyNDU5NTIxNjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaca6f0d1bbe7cf8cb29791b8a9a1c433328efc127f61756a682f65b7f4ab7f3abf
hovercard-subject-tagissue:2346738959
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-microscope/microscope/302/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5249e6362751a51e38fa35768d42743cda3499d7f39b4a42193c5d6ba53ad9a1/python-microscope/microscope/issues/302
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5249e6362751a51e38fa35768d42743cda3499d7f39b4a42193c5d6ba53ad9a1/python-microscope/microscope/issues/302
og:image:altI implemented a draft of an abc.SLM in here. Very much like abc.DM Code below. Any comments or feedback? class SpatialLightModulator(TriggerTargetMixin, Device, metaclass=abc.ABCMeta): """Base clas...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejuliomateoslangerak
hostnamegithub.com
expected-hostnamegithub.com
None42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b
turbo-cache-controlno-preview
go-importgithub.com/python-microscope/microscope git https://github.com/python-microscope/microscope.git
octolytics-dimension-user_id58992974
octolytics-dimension-user_loginpython-microscope
octolytics-dimension-repository_id68124661
octolytics-dimension-repository_nwopython-microscope/microscope
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id68124661
octolytics-dimension-repository_network_root_nwopython-microscope/microscope
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release848bc6032dcc93a9a7301dcc3f379a72ba13b96e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/python-microscope/microscope/issues/302#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-microscope%2Fmicroscope%2Fissues%2F302
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-microscope%2Fmicroscope%2Fissues%2F302
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python-microscope%2Fmicroscope
Reloadhttps://patch-diff.githubusercontent.com/python-microscope/microscope/issues/302
Reloadhttps://patch-diff.githubusercontent.com/python-microscope/microscope/issues/302
Reloadhttps://patch-diff.githubusercontent.com/python-microscope/microscope/issues/302
python-microscope https://patch-diff.githubusercontent.com/python-microscope
microscopehttps://patch-diff.githubusercontent.com/python-microscope/microscope
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-microscope%2Fmicroscope
Fork 42 https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-microscope%2Fmicroscope
Star 82 https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-microscope%2Fmicroscope
Code https://patch-diff.githubusercontent.com/python-microscope/microscope
Issues 112 https://patch-diff.githubusercontent.com/python-microscope/microscope/issues
Pull requests 2 https://patch-diff.githubusercontent.com/python-microscope/microscope/pulls
Actions https://patch-diff.githubusercontent.com/python-microscope/microscope/actions
Security 0 https://patch-diff.githubusercontent.com/python-microscope/microscope/security
Insights https://patch-diff.githubusercontent.com/python-microscope/microscope/pulse
Code https://patch-diff.githubusercontent.com/python-microscope/microscope
Issues https://patch-diff.githubusercontent.com/python-microscope/microscope/issues
Pull requests https://patch-diff.githubusercontent.com/python-microscope/microscope/pulls
Actions https://patch-diff.githubusercontent.com/python-microscope/microscope/actions
Security https://patch-diff.githubusercontent.com/python-microscope/microscope/security
Insights https://patch-diff.githubusercontent.com/python-microscope/microscope/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/python-microscope/microscope/issues/302
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/python-microscope/microscope/issues/302
Draft abc.SLM feedback wantedhttps://patch-diff.githubusercontent.com/python-microscope/microscope/issues/302#top
enhancementhttps://github.com/python-microscope/microscope/issues?q=state%3Aopen%20label%3A%22enhancement%22
help wantedhttps://github.com/python-microscope/microscope/issues?q=state%3Aopen%20label%3A%22help%20wanted%22
https://github.com/juliomateoslangerak
https://github.com/juliomateoslangerak
juliomateoslangerakhttps://github.com/juliomateoslangerak
on Jun 11, 2024https://github.com/python-microscope/microscope/issues/302#issue-2346738959
herehttps://github.com/juliomateoslangerak/microscope/tree/implement_SLM
enhancementhttps://github.com/python-microscope/microscope/issues?q=state%3Aopen%20label%3A%22enhancement%22
help wantedhttps://github.com/python-microscope/microscope/issues?q=state%3Aopen%20label%3A%22help%20wanted%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.