Re: [julia-users] package compatibility for julia v0.3 and v0.4

2015-08-19 Thread Samuele Carcagno

On 19/08/15 02:01, Yichao Yu wrote:

On Tue, Aug 18, 2015 at 8:20 PM, Samuele Carcagno
 wrote:

On 19/08/15 00:22, Stefan Karpinski wrote:


Did you try `@compat x % UInt8`?



yes, it gives the same error `ERROR: `rem` has no method matching
rem(::Int32, ::Type{Uint8})`


Sorry, didn't realize you are converting to a smaller type. Have you
tried just `trunc(Uint8, x)`? (or `@compat trunc(UInt8, x)` if you
want to use the new type name)


this works on julia v0.3

using Compat
x = @compat Int32(2^8)
@compat trunc(UInt8, x)

but fails on julia v0.4 with `ERROR: InexactError()
 in trunc at int.jl:258`

Sam







On Tue, Aug 18, 2015 at 7:18 PM, Samuele Carcagno
mailto:sam.carca...@gmail.com>> wrote:

 On 18/08/15 21:46, Yichao Yu wrote:


 On Aug 18, 2015 2:54 PM, "Samuele Carcagno"
 mailto:sam.carca...@gmail.com>
 >>

 wrote:
   >
   > I understand that if I release a new version of a package
 "foo" and
 put `julia 0.4` in `REQUIRE`, the package won't be updated in
 julia v0.3
 installations. If, after the updated package is released,
 somebody tries
 to install package "foo" from julia v0.3 what happens? Will they
 still
 be able to install the older version of the package?
   >
   > I'm asking because I'd like to release an updated version of a
 package to make it work with julia v0.4. The changes, however, are
 incompatible with julia v0.3. I tried using @compat to work
 around the
 issues but couldn't figure out how to fix this deprecation warning
 without breaking v0.3 compatibility:
   > `uint8(x::Integer) is deprecated, use x % UInt8 instead`

 @compat UInt8(x)


 thanks for the suggestion but that doesn't do what I need. The
 problem is that I need to write 32-bit integers into a 24-bit file
 format. This requires some bit fiddling. In julia v0.3 this worked
 without deprecation warnings:

  write(fid, uint8(thisSample));
  write(fid, uint8(thisSample >> 8));
  write(fid, uint8(thisSample >> 16));

 `thisSample` is a 32 bit integer. In julia v0.4 `UInt8(x)` fails
 when `x` is greater tha 2^8-1, instead the following works:

  write(fid, thisSample % UInt8);
  write(fid, (thisSample >> 8) % UInt8);
  write(fid, (thisSample >> 16) % UInt8);

 the problem is it doesn't work in julia v0.3 `x % @compat UInt8`
gives:
 `ERROR: `rem` has no method matching rem(::Int32, ::Type{Uint8})`



 Sam


   >
   > Cheers,
   >
   > Sam









Re: [julia-users] package compatibility for julia v0.3 and v0.4

2015-08-18 Thread Steven G. Johnson


On Tuesday, August 18, 2015 at 7:22:49 PM UTC-4, Stefan Karpinski wrote:
>
> Did you try `@compat x % UInt8`?
>

You shouldn't need the @compat macro.  The Compat package should just add 
methods to % (rem). 


Re: [julia-users] package compatibility for julia v0.3 and v0.4

2015-08-18 Thread Yichao Yu
On Tue, Aug 18, 2015 at 8:20 PM, Samuele Carcagno
 wrote:
> On 19/08/15 00:22, Stefan Karpinski wrote:
>>
>> Did you try `@compat x % UInt8`?
>
>
> yes, it gives the same error `ERROR: `rem` has no method matching
> rem(::Int32, ::Type{Uint8})`

Sorry, didn't realize you are converting to a smaller type. Have you
tried just `trunc(Uint8, x)`? (or `@compat trunc(UInt8, x)` if you
want to use the new type name)

>
>>
>> On Tue, Aug 18, 2015 at 7:18 PM, Samuele Carcagno
>> mailto:sam.carca...@gmail.com>> wrote:
>>
>> On 18/08/15 21:46, Yichao Yu wrote:
>>
>>
>> On Aug 18, 2015 2:54 PM, "Samuele Carcagno"
>> mailto:sam.carca...@gmail.com>
>> >>
>>
>> wrote:
>>   >
>>   > I understand that if I release a new version of a package
>> "foo" and
>> put `julia 0.4` in `REQUIRE`, the package won't be updated in
>> julia v0.3
>> installations. If, after the updated package is released,
>> somebody tries
>> to install package "foo" from julia v0.3 what happens? Will they
>> still
>> be able to install the older version of the package?
>>   >
>>   > I'm asking because I'd like to release an updated version of a
>> package to make it work with julia v0.4. The changes, however, are
>> incompatible with julia v0.3. I tried using @compat to work
>> around the
>> issues but couldn't figure out how to fix this deprecation warning
>> without breaking v0.3 compatibility:
>>   > `uint8(x::Integer) is deprecated, use x % UInt8 instead`
>>
>> @compat UInt8(x)
>>
>>
>> thanks for the suggestion but that doesn't do what I need. The
>> problem is that I need to write 32-bit integers into a 24-bit file
>> format. This requires some bit fiddling. In julia v0.3 this worked
>> without deprecation warnings:
>>
>>  write(fid, uint8(thisSample));
>>  write(fid, uint8(thisSample >> 8));
>>  write(fid, uint8(thisSample >> 16));
>>
>> `thisSample` is a 32 bit integer. In julia v0.4 `UInt8(x)` fails
>> when `x` is greater tha 2^8-1, instead the following works:
>>
>>  write(fid, thisSample % UInt8);
>>  write(fid, (thisSample >> 8) % UInt8);
>>  write(fid, (thisSample >> 16) % UInt8);
>>
>> the problem is it doesn't work in julia v0.3 `x % @compat UInt8`
>> gives:
>> `ERROR: `rem` has no method matching rem(::Int32, ::Type{Uint8})`
>>
>>
>>
>> Sam
>>
>>
>>   >
>>   > Cheers,
>>   >
>>   > Sam
>>
>>
>>
>


Re: [julia-users] package compatibility for julia v0.3 and v0.4

2015-08-18 Thread Samuele Carcagno

On 19/08/15 00:22, Stefan Karpinski wrote:

Did you try `@compat x % UInt8`?


yes, it gives the same error `ERROR: `rem` has no method matching 
rem(::Int32, ::Type{Uint8})`




On Tue, Aug 18, 2015 at 7:18 PM, Samuele Carcagno
mailto:sam.carca...@gmail.com>> wrote:

On 18/08/15 21:46, Yichao Yu wrote:


On Aug 18, 2015 2:54 PM, "Samuele Carcagno"
mailto:sam.carca...@gmail.com>
>>
wrote:
  >
  > I understand that if I release a new version of a package
"foo" and
put `julia 0.4` in `REQUIRE`, the package won't be updated in
julia v0.3
installations. If, after the updated package is released,
somebody tries
to install package "foo" from julia v0.3 what happens? Will they
still
be able to install the older version of the package?
  >
  > I'm asking because I'd like to release an updated version of a
package to make it work with julia v0.4. The changes, however, are
incompatible with julia v0.3. I tried using @compat to work
around the
issues but couldn't figure out how to fix this deprecation warning
without breaking v0.3 compatibility:
  > `uint8(x::Integer) is deprecated, use x % UInt8 instead`

@compat UInt8(x)


thanks for the suggestion but that doesn't do what I need. The
problem is that I need to write 32-bit integers into a 24-bit file
format. This requires some bit fiddling. In julia v0.3 this worked
without deprecation warnings:

 write(fid, uint8(thisSample));
 write(fid, uint8(thisSample >> 8));
 write(fid, uint8(thisSample >> 16));

`thisSample` is a 32 bit integer. In julia v0.4 `UInt8(x)` fails
when `x` is greater tha 2^8-1, instead the following works:

 write(fid, thisSample % UInt8);
 write(fid, (thisSample >> 8) % UInt8);
 write(fid, (thisSample >> 16) % UInt8);

the problem is it doesn't work in julia v0.3 `x % @compat UInt8` gives:
`ERROR: `rem` has no method matching rem(::Int32, ::Type{Uint8})`



Sam


  >
  > Cheers,
  >
  > Sam







Re: [julia-users] package compatibility for julia v0.3 and v0.4

2015-08-18 Thread Stefan Karpinski
Did you try `@compat x % UInt8`?

On Tue, Aug 18, 2015 at 7:18 PM, Samuele Carcagno 
wrote:

> On 18/08/15 21:46, Yichao Yu wrote:
>
>>
>> On Aug 18, 2015 2:54 PM, "Samuele Carcagno" > > wrote:
>>  >
>>  > I understand that if I release a new version of a package "foo" and
>> put `julia 0.4` in `REQUIRE`, the package won't be updated in julia v0.3
>> installations. If, after the updated package is released, somebody tries
>> to install package "foo" from julia v0.3 what happens? Will they still
>> be able to install the older version of the package?
>>  >
>>  > I'm asking because I'd like to release an updated version of a
>> package to make it work with julia v0.4. The changes, however, are
>> incompatible with julia v0.3. I tried using @compat to work around the
>> issues but couldn't figure out how to fix this deprecation warning
>> without breaking v0.3 compatibility:
>>  > `uint8(x::Integer) is deprecated, use x % UInt8 instead`
>>
>> @compat UInt8(x)
>>
>
> thanks for the suggestion but that doesn't do what I need. The problem is
> that I need to write 32-bit integers into a 24-bit file format. This
> requires some bit fiddling. In julia v0.3 this worked without deprecation
> warnings:
>
> write(fid, uint8(thisSample));
> write(fid, uint8(thisSample >> 8));
> write(fid, uint8(thisSample >> 16));
>
> `thisSample` is a 32 bit integer. In julia v0.4 `UInt8(x)` fails when `x`
> is greater tha 2^8-1, instead the following works:
>
> write(fid, thisSample % UInt8);
> write(fid, (thisSample >> 8) % UInt8);
> write(fid, (thisSample >> 16) % UInt8);
>
> the problem is it doesn't work in julia v0.3 `x % @compat UInt8` gives:
> `ERROR: `rem` has no method matching rem(::Int32, ::Type{Uint8})`
>
>
>
> Sam
>
>
>>  >
>>  > Cheers,
>>  >
>>  > Sam
>>
>>
>


Re: [julia-users] package compatibility for julia v0.3 and v0.4

2015-08-18 Thread Samuele Carcagno

On 18/08/15 21:46, Yichao Yu wrote:


On Aug 18, 2015 2:54 PM, "Samuele Carcagno" mailto:sam.carca...@gmail.com>> wrote:
 >
 > I understand that if I release a new version of a package "foo" and
put `julia 0.4` in `REQUIRE`, the package won't be updated in julia v0.3
installations. If, after the updated package is released, somebody tries
to install package "foo" from julia v0.3 what happens? Will they still
be able to install the older version of the package?
 >
 > I'm asking because I'd like to release an updated version of a
package to make it work with julia v0.4. The changes, however, are
incompatible with julia v0.3. I tried using @compat to work around the
issues but couldn't figure out how to fix this deprecation warning
without breaking v0.3 compatibility:
 > `uint8(x::Integer) is deprecated, use x % UInt8 instead`

@compat UInt8(x)


thanks for the suggestion but that doesn't do what I need. The problem 
is that I need to write 32-bit integers into a 24-bit file format. This 
requires some bit fiddling. In julia v0.3 this worked without 
deprecation warnings:


write(fid, uint8(thisSample));
write(fid, uint8(thisSample >> 8));
write(fid, uint8(thisSample >> 16));

`thisSample` is a 32 bit integer. In julia v0.4 `UInt8(x)` fails when 
`x` is greater tha 2^8-1, instead the following works:


write(fid, thisSample % UInt8);
write(fid, (thisSample >> 8) % UInt8);
write(fid, (thisSample >> 16) % UInt8);

the problem is it doesn't work in julia v0.3 `x % @compat UInt8` gives:
`ERROR: `rem` has no method matching rem(::Int32, ::Type{Uint8})`



Sam



 >
 > Cheers,
 >
 > Sam





Re: [julia-users] package compatibility for julia v0.3 and v0.4

2015-08-18 Thread Yichao Yu
On Aug 18, 2015 2:54 PM, "Samuele Carcagno"  wrote:
>
> I understand that if I release a new version of a package "foo" and put
`julia 0.4` in `REQUIRE`, the package won't be updated in julia v0.3
installations. If, after the updated package is released, somebody tries to
install package "foo" from julia v0.3 what happens? Will they still be able
to install the older version of the package?
>
> I'm asking because I'd like to release an updated version of a package to
make it work with julia v0.4. The changes, however, are incompatible with
julia v0.3. I tried using @compat to work around the issues but couldn't
figure out how to fix this deprecation warning without breaking v0.3
compatibility:
> `uint8(x::Integer) is deprecated, use x % UInt8 instead`

@compat UInt8(x)

>
> Cheers,
>
> Sam


[julia-users] package compatibility for julia v0.3 and v0.4

2015-08-18 Thread Samuele Carcagno
I understand that if I release a new version of a package "foo" and put 
`julia 0.4` in `REQUIRE`, the package won't be updated in julia v0.3 
installations. If, after the updated package is released, somebody tries 
to install package "foo" from julia v0.3 what happens? Will they still 
be able to install the older version of the package?


I'm asking because I'd like to release an updated version of a package 
to make it work with julia v0.4. The changes, however, are incompatible 
with julia v0.3. I tried using @compat to work around the issues but 
couldn't figure out how to fix this deprecation warning without breaking 
v0.3 compatibility:

`uint8(x::Integer) is deprecated, use x % UInt8 instead`

Cheers,

Sam