Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Do not use 'is' for numeric literal comparisons #68

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

Merged

Conversation

rpanderson
Copy link
Member

These elicit a SyntaxWarning since Python 3.8 (explanation).

@chrisjbillington
Copy link
Member

Sweet. Fixes #56

@chrisjbillington chrisjbillington merged commit 0e23ed0 into labscript-suite:master Jun 24, 2020
@chrisjbillington chrisjbillington mentioned this pull request Jun 24, 2020
@rpanderson rpanderson deleted the is-syntax-warning branch June 25, 2020 00:52
@rpanderson
Copy link
Member Author

This introduced a bug when arrays[0] is an array.

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

@chrisjbillington
Copy link
Member

chrisjbillington commented Jun 25, 2020

I've never had a good rule for what to use in this situation. Neither any() or all() is approriate, and we don't want to do a typecheck on it being an int since it's allowed to be float zero as well.

Maybe

if not isinstance(arrays[0], np.ndarray) and arrays[0] == 0:

@chrisjbillington
Copy link
Member

chrisjbillington commented Jun 25, 2020

Ah,

if np.array_equal(arrays[0], 0):

appears to do the trick

Always returns False for differing shapes, and for scalars is equivalent to ==. I think it's the right solution.

rpanderson added a commit to rpanderson/labscript that referenced this pull request Jun 25, 2020
chrisjbillington added a commit that referenced this pull request Jun 25, 2020
philipstarkey added a commit that referenced this pull request Jun 25, 2020
commit c3b7988
Author: Phil Starkey <[email protected]>
Date:   Thu Jun 25 18:27:06 2020 +1000

    Update labscript_utils dependency to `>=3.0.0`

commit 822e5d5
Merge: 2e2785c 39c6f0b
Author: Russell Anderson <[email protected]>
Date:   Thu Jun 25 15:48:15 2020 +1000

    Merge pull request #69 from rpanderson/example_fix

    Make example labscript functional and format using black

commit 39c6f0b
Author: Russell Anderson <[email protected]>
Date:   Thu Jun 25 12:34:08 2020 +1000

    Name all the args

commit 255d74e
Author: Russell Anderson <[email protected]>
Date:   Thu Jun 25 12:11:48 2020 +1000

    Name all arguments in connection table

commit e3d3ece
Author: Russell Anderson <[email protected]>
Date:   Thu Jun 25 11:08:25 2020 +1000

    Omit __init__ import and comply with flake8 F403

commit 6b26f1f
Author: Russell Anderson <[email protected]>
Date:   Sun May 31 17:38:18 2020 +1000

    Make example labscript functional and format using black

commit 2e2785c
Merge: 62b9098 4e77810
Author: Chris Billington <[email protected]>
Date:   Wed Jun 24 21:22:05 2020 -0400

    Merge pull request #70 from rpanderson/is-syntax-warning-bugfix

    Bugfix for ValueError introduced in #68

commit 4e77810
Author: Russell Anderson <[email protected]>
Date:   Thu Jun 25 11:18:56 2020 +1000

    Abbreviated bugfix.

commit a667f7e
Author: Russell Anderson <[email protected]>
Date:   Thu Jun 25 11:17:11 2020 +1000

    Bugfix for ValueError introduced in #68

commit 62b9098
Merge: 0e23ed0 1746399
Author: Chris Billington <[email protected]>
Date:   Wed Jun 24 20:49:32 2020 -0400

    Merge pull request #67 from philipstarkey/fix-h5py-file-mode

    Fix h5py deprecation warning

commit 0e23ed0
Merge: 5b52c20 6373f02
Author: Chris Billington <[email protected]>
Date:   Wed Jun 24 18:47:18 2020 -0400

    Merge pull request #68 from rpanderson/is-syntax-warning

    Do not use 'is' for numeric literal comparisons

commit 6373f02
Author: Russell Anderson <[email protected]>
Date:   Thu Jun 25 08:36:55 2020 +1000

    Omitted 'is' with numeric literal comparisons

commit 1746399
Author: philipstarkey <[email protected]>
Date:   Wed Jun 24 18:29:12 2020 +1000

    Fix h5py deprecation warning

    Addresses labscript-suite/labscript-utils#47 for the labscript module

commit 5b52c20
Merge: 0362fa7 88ce952
Author: Russell Anderson <[email protected]>
Date:   Mon Jun 22 18:09:54 2020 +1000

    Merge pull request #66 from philipstarkey/master

    Doc updates

commit 88ce952
Author: philipstarkey <[email protected]>
Date:   Sat Jun 20 18:17:23 2020 +1000

    Doc updates

    Renamed API reference URL to match labscript utils and updated config to fix bugs identified in labscript-suite/labscript-utils#57

commit 0362fa7
Merge: 74869ef 52d3b9f
Author: Phil Starkey <[email protected]>
Date:   Fri Jun 19 18:58:04 2020 +1000

    Merge pull request #65 from philipstarkey/master

    Updated docs to follow our standard conf

commit 52d3b9f
Author: philipstarkey <[email protected]>
Date:   Fri Jun 19 16:04:04 2020 +1000

    Addressing latest review comments

commit 7674a8f
Author: philipstarkey <[email protected]>
Date:   Fri Jun 19 11:19:33 2020 +1000

    Updated docs to use jinja template for component doc links

commit d4474e2
Author: philipstarkey <[email protected]>
Date:   Thu Jun 18 16:43:10 2020 +1000

    Updated .gitignore with latest GitHub defaults

commit a18a0d1
Author: philipstarkey <[email protected]>
Date:   Thu Jun 18 16:39:35 2020 +1000

    Relocated custom sphinx git ignore rules

commit 80aa5a1
Author: philipstarkey <[email protected]>
Date:   Thu Jun 18 16:21:44 2020 +1000

    Restored 64 pixel logo accidentally replaced with 32 pixel logo

commit 42d3bc6
Author: philipstarkey <[email protected]>
Date:   Thu Jun 18 16:17:42 2020 +1000

    Updated install requirement to 3.0.0rc1+

commit 1961a2c
Author: philipstarkey <[email protected]>
Date:   Thu Jun 18 16:13:40 2020 +1000

    testing dependency fix

commit 234753d
Author: philipstarkey <[email protected]>
Date:   Thu Jun 18 16:07:41 2020 +1000

    Updated as per the review in labscript-suite/labscript-suite#48

commit 74869ef
Author: Russell Anderson <[email protected]>
Date:   Wed Jun 17 10:24:43 2020 +1000

    Populated README.md with styling, iconogrpahy, prose, and badges

commit 28dc675
Author: philipstarkey <[email protected]>
Date:   Tue Jun 16 18:24:26 2020 +1000

    Removed unnecessary header and added intersphinx link

commit 35c5466
Author: philipstarkey <[email protected]>
Date:   Tue Jun 16 17:19:33 2020 +1000

    Updated docs to follow our standard conf

    Also added links to other labscript suite docs and standard links.

Co-authored-by: chrisjbillington <[email protected]>
Co-authored-by: Russell Anderson <[email protected]>
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.

2 participants