Show more

Back to dark and light modes.

For someone with high higher-order aberrations (like me), dark mode pushes the pupil size well above the ideal pupil size, therefore vision is worse.

This will not be the case for everyone, of course.

But, dark mode is not for everyone…

If, like me, you prefer light mode, ignore all those who snigger because “pros use dark mode”

/6

Show thread

So, in the human eye, there is an optimum pupil size. If the pupil is very small, diffraction leads to lower resolution…

If the pupil is too large, higher-order aberrations lead to lower resolution.

The sweet spot varies from person to person (it’s roughly around 3-5mm — the pupil typically can vary between 2-8mm in an average eye)

/5

Show thread

How about diffraction?

Diffraction is something completely different… It’s a fundamental optical phenomenon

All optical systems suffer from this, even ones that have no aberrations (imperfections)

Small pupils lead to more diffraction which reduces resolution.

Large pupils have less diffraction and therefore have less of an effect on resolution.

This is why telescopes have large diameters and professional photographers have lenses with larger diameters.

/4

Show thread

Every eye has aberrations, or imperfections…

…and these are not just the ones we correct using glasses or contact lenses.

Those are just the main ones.

The others are called higher-order aberrations.

The larger the pupil of the eye, the more higher-order aberrations there are.

Therefore, in bright lights, when the pupils are small, there aren’t many higher order aberrations…

But when the light levels are low and the pupils large, there are significantly more.

Everyone has higher-order aberrations, but not everyone has the same amount.

So this is worse for some people.

I happen to know that I have reasonably high higher-order aberrations (How do I know this: from my previous work as a scientist when I often measured these)

More aberrations = lower resolution and lower contrast = poorer vision.

/3

Show thread

I used PyCharm’s Darcula and IntelliJ Light themes on a 27” screen — PyCharm was in full screen mode. iMac was on 75% brightness (usual setting)

I stood in my normal position—arm’s length from screen—and looked at the middle of the screen…

Here’s my eye pupil as I switch from dark mode to light mode

Video quality not great (don’t view in full screen!!)—but this is just a rough experiment, so it will do nicely

And you can see stills, with a very rough estimate of the relative pupil sizes, in the first toot…

On the right you’ll see the small pupil from the light mode scenario shown in red and superimposed on the black “dark mode” pupil

/2

Show thread

There’s plenty of disagreement and controversy at the moment, so let me stoke things a bit more:

Light Mode is better than Dark Mode (for me)

Here’s why, with some science behind it, too. Yes, I have a justification as well just a preference…

Let’s start with what we know:
The pupil of the eye shrinks when there’s a lot of light and dilates when it’s darker

The question is: how much difference will it make between viewing a screen in dark mode and light mode?

Here’s a very rough, crude experiment (emphasis on “rough” and “crude”, and use of “experiment” is very loose here!)

Details in next toot

/1

As of Python 3.10, all the binary search helpers in the bisect module now accept a key argument.

Read the full article: What's great about Python 3.10?
trey.io/ci2i5f

#Python

But, there are times when you want to know that an object is exactly the same object and not just equal in value.

In these cases, you’ll need to use `is`.

As a general rule, use `==` by default unless you know you need `is`.

But now can we stop squabbling about who the £5 note belongs to?!

/5

Show thread

Sorry, the serial number of the note shows it’s _mine_!

This *is* my note. In this case, it wasn’t `==` that matters but `is`

With a object, the built-in `id()` function gives you the “serial number”, which is unique for each object, just as the serial number on a bank note is unique.

In , as in the case with bank notes, you often care more about the value of an object rather than its identity.

So, you’ll often need `==` just like the barista in the coffee shop didn’t care about the £5 note’s serial number.

/4

Show thread

Its value is no longer what matters now.

We both had a £5 note.

What matters is whether this is the actual physical note that was in my pocket or yours.

Luckily, we’re both geeks and we keep a record of the serial numbers of all the notes we carry with us on our phone.

I know, that’s quite sad.

And quite unlikely, too.

But bear with me.

So, we both get our phones out to check the serial numbers on record against the serial number on the £5 note on the floor.

You can see the serial number in two places on the £5 note.

/3

Show thread

So, does it matter which £5 note we use to pay?

No, all the barista cares about is that `our_payment == 5`

So _you_ can pay. Thank you!

In this case, the *value* of the £5 note is what matters, not which actual physical note we use.

But let’s assume we’re chatting and we spot a £5 note on the floor.

We both check our pockets and we realise we’ve both lost our £5 note.

Is the note on the floor mine or yours?

/2

Show thread

Have you heard the one about `is`, `==`, and the £5 note that it’s your pocket?

You may have already come across the fact that `is` and `==` are not the same in Python and cannot be used interchangeably… if you haven’t, you heard it now!

But why? Let’s see what the £5 note has got to do with this story

Let’s assume you and I both have a £5 note in our pocket

[replace with currency of choice]
and
[read “bill” instead of “note” if you wish]

We meet up and go to a coffee shop nearby to buy two coffees which cost £5 altogether

Does it matter which £5 note we use to pay?

/1

[this is like a Netflix series you can binge on, no need to wait until next week for the next episode, read on in the next toot in this thread…]

question: What are the pros of autodeleting toots? Only people who browse you profile will ever see them after the initial posting and any boosts, so why not leave them there?

Later this week, I’ll look at other aspects relating to that can confuse those beginners moving on to more intermediate levels, including:

positional and named arguments
optional arguments (by defining default values)
• the “obscure” args and kwargs
• forcing positional-only or keyword-only arguments using the “rogue” forward slash / and asterisk * in the function signature
type-hinting when defining functions
• some best practices when defining and using functions

Some of these topics I’ve written about a while ago in this Real Python article: realpython.com/python-optional

Show thread

“What’s in a name?”, one might argue? And there’s a point. What matters most is knowing how to use concepts rather than knowing the precise definitions

Still, these terms are used everywhere-in documentation, in tutorials, when talking to other programmers

So, knowing the terminology is important. It shouldn’t be the first thing someone learns, but eventually, everyone should become familiar with the right terms for the right things

/6

Show thread

— Argument —

An argument is the actual information you send to a function when you call it

You called the function twice in the example above

The first time you called greet_person() you used the argument "Ishaan" and the second time "Elizabeth"

When you call the function, the information (the argument) is stored in a variable named person inside the function

Don’t worry too much if you confuse parameters and arguments. Many programmers confuse them, too!

/5

Show thread

— Parameter —

A parameter is the name you choose for information that’s needed by the function

You add parameters inside the brackets in the function signature which is the line which includes def

In this example, the parameter is person

This is the name of the “storage box” which is ready to hold any information you send into the function

However, when you define the function, this “box” is still empty…

/4

Show thread

— Call —

You call a function when you use it

You’re calling a function when you write its name followed by parenthesis (the round brackets)…

The code in the function definition will run when you call a function

In the example above, you’re calling the function twice on the last two lines of the code

/3

Show thread

— Define —

You define the function when you use the def keyword

The first line of the definition is the function signature and the code after the colon is the code you want the function to perform…

However, this code does not run when you define a function

For this, we need to call the function…

/2

Show thread

Functions in Python—easy or hard to learn & master?

This week I’ll be looking at aspects of functions which can be tricky for those who know basics and want to move to next level. If you’ve learnt about functions in Python are keen to take the next step, then hopefully this series of toots will help…

Let’s start with the unexciting but important—terms

define
call
parameter
argument

Here’s the code we’ll use as an example which you can also get from the ALT text of the image in this toot:

def greet_person(person):
print(f"Hello {person}! How are you doing today?")

greet_person("Ishaan")
greet_person("Elizabeth")

You can follow this thread in the replies (unlisted)

/1

Show more
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.