## functional programming – In Scala, converting CSV into map using first line values as keys and columns values as arrays

I have this format data in CSV :

``````A,B,C,D
1,2,3,4
5,6,7,8
9,10,11,12
``````

And I need to convert it to map of below format, using lambda expression (no loops)

``````HashMap<String,mutable.ArrayBuffer(Double)> = new HashMap<>()
("A"->{1,5,9}, "B"->{2,6,10}, "C"->{3,7,11}, "D"->{4,8,12})
``````

Thanks!

## hard drive – After converting SSD to APFS MacBook 2014 doesn’t boot anymore

Good morning,

My MacBook 2014 with TouchBar doesn’t boot anymore when going from its original Sierra to newer operating systems, e.g. High Sierra or Big Sur. One morning the computer just refused to boot, and got stuck in the login process. I was able to still log in, sometimes, but after opening an app, the Mac gave a kernel panic. Various tests later, reformatting the drive, and resetting everything, eventually I was able to use Internet Recovery, to install the original Sierra OS, which still uses HFS+. Naturally I tried installing Big Sur first, but got the same issues right after upgrading. I then tried going in steps, using gibMacOS, from Sierra, to High Sierra. But even High Sierra produced the same issues. I was in Disk Utility that installing High Sierra, already formatted the drive to APFS, so my conclusion now is that something makes the computer stop working after the converting to APFS.

Ideally I would love to get Big Sur again up and running, but I don’t know what steps I can take to make that happen. My hunch is that some sectors on the drive are just so damaged, because of wear and tear that it’s now impossible to get it formatted to APFS. I hope I’m wrong though.

Summary:

MacBook refuses to boot after its drive gets converted to APFS it seems. Restoring Sierra makes the computer work again, but any upgrading attempts to High Sierra or Big Sur, resulted in the same issues the Mac had, which started this entire problem.

## Converting python/numpy code into pseudocode

I’ve written some code that uses numpy’s array broadcasting logic and need to convert it to pseudocode. Basically, $$win R^{T}$$ and $$betain R^{T times M}$$. If you have the following code using numpy arrays:

``````T = 100
M = 10
w = np.ones(T) / T
b = np.ones((T, M))
x = (w * b).sum(axis=0)
``````

Numpy will automatically broadcast `w` to the correct axis of `b` and `x` becomes the weighted average of `b` along `axis=1`. How do I convert something like this into pseudocode?

## color management – Converting from sRGB to ProPhoto & vice versa on Photoshop (with a 120% sRGB screen)

I want to find a cyclical way to convert from sRGB to ProPhoto and vice-versa on Photoshop.

1. I notice that no matter that the images from Is Your Browser Color-Managed? looks different inside of PS…

2. the browser renders both identical and that’s the goal of the ICC profile, I know.

3. But, when I try to change the color profile of the proPhoto one to sRGB on PS (with “convert to profile…” and “assign profile”) that doesn’t work and actually looks the same on PS and of course renders different on the browser.

4. And with the same resultant image I tried to convert it back to proPhoto and that doesn’t work either.

5. There is a cyclical way to convert a image between sRGB and Prophoto and making them to looks the same on the browser?

Edit

To consider:

• My main display is a Huion Kamvas 13 with 120% sRGB according to the manufacturer.
• Because of that the image on the ProPhoto space won’t look the same as the sRGB one without proofing colors.
• The original image tagged with sRGB doesn’t have a ICC profile, but by default the browser will assume it as sRGB, not the same with Photoshop.

Regardless of my browser shows them the same, Photoshop show them different without proofing colors and also different with sRGB internet proofing colors. They only look the same if I only set the unprofiled one (sRGB tagged) to sRGB proof colors.

• For the unmanaged image with no proof colors I guess that PS stretch the RGB colors (oversaturating them) to my larger 120% sRGB space right?
• For the ProPhoto with sRGB proof colors I guess is like to have double conversion first from ProPhoto to 120% sRGB and than to 100% rgb. That implies that in a 100% rgb that image will look right Isn’t it?

After a kind of laboratory a realized (I think) that my 120% sRGB screen (or driver) tells to PS to operates the transformations with that space when converting color profiles as you can see in the “sRGB Converted to ProPhoto” (1st row, 2nd col) resulting in wrong colors. But if I tell to PS that the unmanaged image is on the sRGB space assigning it a sRGB profile before I convert to the ProPhoto space, PS do the works correcly

Now I want to go back from ProPhoto to sRGB

Here you an see that if I just assign a sRGB profile to the ProPhoto (sRGB, sRGB assigned, Converted to ProPhoto) image the colors get borked as @Tetsujin mentioned. But if a converted to sRGB and then remove the color management I’m able to get back a image virtualy equal to the original sRGB one

You will be able to calculate the RGB values that PS calculates with this calculator
http://www.brucelindbloom.com/index.html?ColorCalculator.html
First go from sRGB to XYZ and then to ProPhoto (white D65, gamma 1.8)

Then for the example of Steven Kersting sRGB(0,255,25) is XYZ(0.359330, 0.715854, 0.128430) and ProPhoto(138.0695, 236.5775 80.7067), but with a 8-bit depth with dont have that precision, actually we dont have decimales
so ProPhoto(138, 236, 80) is XYZ(0.358508, 0.712998, 0.126304) and sRGB(9.1773, 254.4782, 21.9759)

So for my question

There is a cyclical way to convert a image between sRGB and Prophoto
and making them to looks the same on the browser?

The answer has three big considerations: What is my native color space (the one that is told by the video driver to the PS), Is the source image color unmanaged or does it have color profiles assigned? and What is the format and color depth of the image?. If my native color space is 100% sRGB I could go straight converting profiles. But if I have another color space than 100% sRGB like me with 120% sRGB then a have to pay attention if the source image has a color profile, if it don’t have one I must assign a color profile before the conversion. Now if I have a 8-bit depth LQ JPEG we’ll be able to see some color distorsion in the cyclical conversions, but if I have a 16-bit uncompressed TIFF I may not see significant differences. In the image below you can see that i managed to replicate the conversion on my 120% sRGB workspace (the bottom-right one).

Consedirations

You will be able to calculate the RGB values that PS calculates with this calculator. First go from sRGB to XYZ and then to ProPhoto (white D65, gamma 1.8). Then for the example of @Steven Kersting, sRGB(0,255,25) is XYZ(0.359330, 0.715854, 0.128430) and ProPhoto(138.0695, 236.5775 80.7067), but with a 8-bit depth we dont have that precision, actually, we don’t have decimals, so for PS to get back, it will be ProPhoto(138, 236, 80) that is XYZ(0.358508, 0.712998, 0.126304) and is sRGB(9.1773, 254.4782, 21.9759) and of course this will be rounded. But this scenario is idealistic because as mention @doug if you set the dither option you will have some kind variation to maintain the average and reducing the error, and even better results if you have a 16-bit color depth

## Converting from sRGB to ProPhoto & vice versa on Photoshop

Just because Photoshop uses the ProPhoto color space internally, it doesn’t mean what you see on your screen is rendered using ProPhoto color space. It’s almost certainly being converted to sRGB when sent to your screen. So what you see on your screen when working in the ProPhoto color space is the results of your processing instructions applied in ProPhoto and then converted to sRGB to be sent to your screen.

This is because your screen is very unlikely to be able to reproduce the entirety of the ProPhoto color space. Most screens are limited to most or all of sRGB. A few more capable screens can render AdobeRGB, but screens that can render ProPhoto are currently nonexistent and will be for the foreseeable future. You computer’s graphics card knows this and converts the image sent to it to the color space it detects the monitor is capable of rendering before sending that image on to the monitor.

Think of it like your primitive scientific calculator back in the 1970s. It had an eight digit display, but the internal processor kept track of numbers up to a much higher number of significant digits. What you saw on the calculator’s display was the internal number rounded to the nearest number using eight significant digits. But when you multiplied that number by π (pi), it multiplied the internal number by π out to, say, 64 significant digits and preserved the outcome internally out to 64 significant digits to reduce rounding errors in the final answer at the end of all calculations, which was then displayed on the screen to eight significant digits. If you then punched in that number into another calculator, you limited the accuracy of the calculations using the second calculator to the initial number that was entered rounded to eight significant digits. The information in the 9th to 64th significant digits was irretrievably lost when you converted the internal 64-digit number to an 8-digit number and entered it on another calculator.

Beyond that, once an image has been converted and exported using a more restrictive color space, such as from ProPhoto to sRGB, if one converts it to another larger color space the image will only use the portion of the larger color space that also fits within the smaller color space. Any values in the original image that are outside of the more restrictive color space are irretrievably lost once the image has been squeezed into the smaller color space.

The way to make your images look the same in all browsers is to:

• Include the color space profile used when you export an image in the metadata of the exported image file
• Use properly color managed browsers that pay attention to the metadata with regard to color space profiles and are capable of rendering an image in the color space used to export the image

Alternatively, you can always export images intended for viewing using browsers in the sRGB color space so that even browsers with poorly implemented or no color management which tend to always use sRGB, regardless of what the color space profile tag in the EXIF info says, will render them correctly in sRGB. This is generally a good practice for any images you plan to share via web services since many image hosting sites, including pretty much almost all social media hosting sites, strip the EXIF data from images anyway.

## Converting from sRGB to ProPhoto y viceversa on Photoshop

I want to find a ciclycal way to convert from sRGB to ProPhoto and viceversa on Photoshop. I notice that no matter that the folowing images (1) (from Is Your Browser Color-Managed?) looks diferent inside of PS, the browser renders both identical (2) and that’s the goal of the ICC profile, I know. But, when I try to change de color profile of the proPhoto one to sRGB (3) on PS (with “convert to profile…” and “assign profile”) that doesn’t work and actually looks the same on PS and of course renders different on the browser. And with the same resultant image I tried to convert it back to proPhoto (4) and that doesn’t work either. There is a cyclical way to convert a image between sRGB and Prophoto and making them to looks the same on the browser?

## Converting a googlefinance() market cap to another currency in Google Sheets

I can get the market capitalization of Bank of Montreal with `=googlefinance("TSE:BMO", "marketcap")`. The result is in US dollars. How do I get it in Canadian dollars?

## optimization – Converting 4 variable if else condition to Linear integer program

There are four variables: x1, x2, x3, x4.

If you choose either x3 or x4 or both – then you should chose exactly one of x1 or x2.
If you choose neither x3 or x4 – then there is no restriction in ch0osing x1 or x2.

I have come up with the following if else logic for this, but cannot proceed from there.

Can you let me know how to come up with a integer linear program with this understanding?

## postgresql – Converting DATE and TIME Ingeters to Timestamp in postgres

I am trying to get a Timestamp by combining Date and Time columns in my PostgresQL database and am running into errors. Here is what I have.

``````+-----------+-----------+
| StartDate | StartTime |
+-----------+-----------+
| 20210301  | 18000000  |
+-----------+-----------+
| 20210302  | 19000000  |
+-----------+-----------+
| 20210303  | 20000000  |
+-----------+-----------+
``````

Here is what I want

``````+-----------+-----------+-----------------------+
| StartDate | StartTime | StartStamp            |
+-----------+-----------+-----------------------+
| 20210301  | 18000000  | 2021-03-01 18:00:00.0 |
+-----------+-----------+-----------------------+
| 20210302  | 19000000  | 2021-03-02 19:00:00.0 |
+-----------+-----------+-----------------------+
| 20210303  | 20000000  | 2021-03-03 20:00:00.0 |
+-----------+-----------+-----------------------+
``````

In MySQL I would be able to get this by using the following sql

``````SELECT  STR_TO_DATE(concat(LPAD("STARTDT", 8, '0'),'-', LEFT(LPAD("STARTTM", 8, '0'),6)),'%Y%m%d-%H%i%s') AS StartStamp
From Table1
``````

To get that in postgres, I’ve tried to CAST(STARTDT as DATE) but that resulted in an error. I’ve tried TO_DATE() but that also did not work. Is there a way to get the timestamp in PostgresQL ?

## Converting a WordPress widget to a block

Is it possible to convert an existing WordPress widget to a block, without having to write a custom block (javascript)?